2014-05-12 07:48:37 -07:00
|
|
|
|
Writing content
|
2010-12-14 15:31:11 +00:00
|
|
|
|
###############
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Articles and pages
|
2014-05-12 07:48:37 -07:00
|
|
|
|
==================
|
2013-04-16 19:45:46 -07:00
|
|
|
|
|
|
|
|
|
|
Pelican considers "articles" to be chronological content, such as posts on a
|
|
|
|
|
|
blog, and thus associated with a date.
|
|
|
|
|
|
|
|
|
|
|
|
The idea behind "pages" is that they are usually not temporal in nature and are
|
|
|
|
|
|
used for content that does not change very often (e.g., "About" or "Contact"
|
|
|
|
|
|
pages).
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2017-08-08 23:45:00 +02:00
|
|
|
|
You can find sample content in the repository at ``samples/content/``.
|
2016-10-22 15:00:52 -06:00
|
|
|
|
|
2013-01-18 19:00:45 -05:00
|
|
|
|
.. _internal_metadata:
|
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
File metadata
|
2014-05-12 07:48:37 -07:00
|
|
|
|
=============
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Pelican tries to be smart enough to get the information it needs from the
|
|
|
|
|
|
file system (for instance, about the category of your articles), but some
|
|
|
|
|
|
information you need to provide in the form of metadata inside your files.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
If you are writing your content in reStructuredText format, you can provide
|
|
|
|
|
|
this metadata in text files via the following syntax (give your file the
|
|
|
|
|
|
``.rst`` extension)::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
|
|
My super title
|
|
|
|
|
|
##############
|
|
|
|
|
|
|
|
|
|
|
|
:date: 2010-10-03 10:20
|
2013-11-05 19:38:58 +01:00
|
|
|
|
:modified: 2010-10-04 18:40
|
2010-12-14 15:31:11 +00:00
|
|
|
|
:tags: thats, awesome
|
|
|
|
|
|
:category: yeah
|
2012-11-24 13:18:49 +02:00
|
|
|
|
:slug: my-super-post
|
2013-07-05 01:08:45 +02:00
|
|
|
|
:authors: Alexis Metaireau, Conan Doyle
|
2012-11-24 13:18:49 +02:00
|
|
|
|
:summary: Short version for index and feeds
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2015-03-21 21:54:06 -04:00
|
|
|
|
Author and tag lists may be semicolon-separated instead, which allows
|
|
|
|
|
|
you to write authors and tags containing commas::
|
|
|
|
|
|
|
|
|
|
|
|
:tags: pelican, publishing tool; pelican, bird
|
|
|
|
|
|
:authors: Metaireau, Alexis; Doyle, Conan
|
|
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
Pelican implements an extension to reStructuredText to enable support for the
|
2012-07-18 18:22:31 +02:00
|
|
|
|
``abbr`` HTML tag. To use it, write something like this in your post::
|
|
|
|
|
|
|
|
|
|
|
|
This will be turned into :abbr:`HTML (HyperText Markup Language)`.
|
|
|
|
|
|
|
2020-05-17 06:26:30 +02:00
|
|
|
|
You can also use Markdown syntax (with a file ending in ``.md``, ``.markdown``,
|
|
|
|
|
|
``.mkd``, or ``.mdown``). Markdown generation requires that you first
|
|
|
|
|
|
explicitly install the Python-Markdown_ package, which can be done via ``pip
|
2014-11-02 22:24:29 +01:00
|
|
|
|
install Markdown``.
|
|
|
|
|
|
|
|
|
|
|
|
Pelican also supports `Markdown Extensions`_, which might have to be installed
|
|
|
|
|
|
separately if they are not included in the default ``Markdown`` package and can
|
2016-11-01 13:02:22 +01:00
|
|
|
|
be configured and loaded via the ``MARKDOWN`` setting.
|
2014-11-02 22:24:29 +01:00
|
|
|
|
|
|
|
|
|
|
Metadata syntax for Markdown posts should follow this pattern::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
|
|
Title: My super title
|
2012-11-24 13:18:49 +02:00
|
|
|
|
Date: 2010-12-03 10:20
|
2013-11-05 19:38:58 +01:00
|
|
|
|
Modified: 2010-12-05 19:30
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Category: Python
|
|
|
|
|
|
Tags: pelican, publishing
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Slug: my-super-post
|
2013-07-05 01:08:45 +02:00
|
|
|
|
Authors: Alexis Metaireau, Conan Doyle
|
2012-11-24 13:18:49 +02:00
|
|
|
|
Summary: Short version for index and feeds
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
This is the content of my super blog post.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
You can also have your own metadata keys (so long as they don't conflict with
|
2019-10-16 15:52:50 -07:00
|
|
|
|
reserved metadata keywords) for use in your templates. The following table
|
|
|
|
|
|
contains a list of reserved metadata keywords:
|
|
|
|
|
|
|
|
|
|
|
|
=============== ===============================================================
|
|
|
|
|
|
Metadata Description
|
|
|
|
|
|
=============== ===============================================================
|
|
|
|
|
|
``title`` Title of the article or page
|
|
|
|
|
|
``date`` Publication date (e.g., ``YYYY-MM-DD HH:SS``)
|
|
|
|
|
|
``modified`` Modification date (e.g., ``YYYY-MM-DD HH:SS``)
|
|
|
|
|
|
``tags`` Content tags, separated by commas
|
|
|
|
|
|
``keywords`` Content keywords, separated by commas (HTML content only)
|
|
|
|
|
|
``category`` Content category (one only — not multiple)
|
|
|
|
|
|
``slug`` Identifier used in URLs and translations
|
|
|
|
|
|
``author`` Content author, when there is only one
|
|
|
|
|
|
``authors`` Content authors, when there are multiple
|
|
|
|
|
|
``summary`` Brief description of content for index pages
|
|
|
|
|
|
``lang`` Content language ID (``en``, ``fr``, etc.)
|
2020-06-12 11:24:42 +00:00
|
|
|
|
``translation`` If content is a translation of another (``true`` or ``false``)
|
2019-10-16 15:52:50 -07:00
|
|
|
|
``status`` Content status: ``draft``, ``hidden``, or ``published``
|
|
|
|
|
|
``template`` Name of template to use to generate content (without extension)
|
|
|
|
|
|
``save_as`` Save content to this relative file path
|
|
|
|
|
|
``url`` URL to use for this article/page
|
|
|
|
|
|
=============== ===============================================================
|
2018-04-01 21:25:41 -04:00
|
|
|
|
|
2014-06-10 18:05:29 -04:00
|
|
|
|
Readers for additional formats (such as AsciiDoc_) are available via plugins.
|
|
|
|
|
|
Refer to `pelican-plugins`_ repository for those.
|
2013-08-07 12:45:26 -07:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Pelican can also process HTML files ending in ``.html`` and ``.htm``. Pelican
|
|
|
|
|
|
interprets the HTML in a very straightforward manner, reading metadata from
|
|
|
|
|
|
``meta`` tags, the title from the ``title`` tag, and the body out from the
|
2012-07-09 22:43:51 -04:00
|
|
|
|
``body`` tag::
|
|
|
|
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<title>My super title</title>
|
2013-06-14 12:12:19 -07:00
|
|
|
|
<meta name="tags" content="thats, awesome" />
|
|
|
|
|
|
<meta name="date" content="2012-07-09 22:28" />
|
2013-11-05 19:38:58 +01:00
|
|
|
|
<meta name="modified" content="2012-07-10 20:14" />
|
2013-06-14 12:12:19 -07:00
|
|
|
|
<meta name="category" content="yeah" />
|
2013-07-05 01:08:45 +02:00
|
|
|
|
<meta name="authors" content="Alexis Métaireau, Conan Doyle" />
|
2013-06-14 12:12:19 -07:00
|
|
|
|
<meta name="summary" content="Short version for index and feeds" />
|
2012-07-09 22:43:51 -04:00
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
This is the content of my super blog post.
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
2017-08-12 21:40:27 +02:00
|
|
|
|
With HTML, there is one simple exception to the standard metadata: tags can be
|
|
|
|
|
|
specified either via the ``tags`` metadata, as is standard in Pelican, or via
|
|
|
|
|
|
the ``keywords`` metadata, as is standard in HTML. The two can be used
|
2013-04-16 19:45:46 -07:00
|
|
|
|
interchangeably.
|
2012-07-09 22:43:51 -04:00
|
|
|
|
|
2019-06-17 17:40:52 +02:00
|
|
|
|
Note that, aside from the title, none of this content metadata is mandatory:
|
2015-01-17 16:19:37 -08:00
|
|
|
|
if the date is not specified and ``DEFAULT_DATE`` is set to ``'fs'``, Pelican
|
2013-04-16 19:45:46 -07:00
|
|
|
|
will rely on the file's "mtime" timestamp, and the category can be determined
|
|
|
|
|
|
by the directory in which the file resides. For example, a file located at
|
|
|
|
|
|
``python/foobar/myfoobar.rst`` will have a category of ``foobar``. If you would
|
|
|
|
|
|
like to organize your files in other ways where the name of the subfolder would
|
|
|
|
|
|
not be a good category name, you can set the setting ``USE_FOLDER_AS_CATEGORY``
|
2013-06-11 21:40:13 -04:00
|
|
|
|
to ``False``. When parsing dates given in the page metadata, Pelican supports
|
|
|
|
|
|
the W3C's `suggested subset ISO 8601`__.
|
|
|
|
|
|
|
2019-06-17 17:40:52 +02:00
|
|
|
|
So the title is the only required metadata. If that bothers you, worry not.
|
|
|
|
|
|
Instead of manually specifying a title in your metadata each time, you can use
|
|
|
|
|
|
the source content file name as the title. For example, a Markdown source file
|
|
|
|
|
|
named ``Publishing via Pelican.md`` would automatically be assigned a title of
|
|
|
|
|
|
*Publishing via Pelican*. If you would prefer this behavior, add the following
|
|
|
|
|
|
line to your settings file::
|
|
|
|
|
|
|
|
|
|
|
|
FILENAME_METADATA = '(?P<title>.*)'
|
|
|
|
|
|
|
2014-11-03 15:30:45 +01:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
|
|
When experimenting with different settings (especially the metadata
|
|
|
|
|
|
ones) caching may interfere and the changes may not be visible. In
|
|
|
|
|
|
such cases disable caching with ``LOAD_CONTENT_CACHE = False`` or
|
|
|
|
|
|
use the ``--ignore-cache`` command-line switch.
|
|
|
|
|
|
|
2013-06-11 21:40:13 -04:00
|
|
|
|
__ `W3C ISO 8601`_
|
2013-02-09 19:43:32 -05:00
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
``modified`` should be last time you updated the article, and defaults to
|
|
|
|
|
|
``date`` if not specified. Besides you can show ``modified`` in the templates,
|
|
|
|
|
|
feed entries in feed readers will be updated automatically when you set
|
|
|
|
|
|
``modified`` to the current date after you modified your article.
|
2013-11-05 19:38:58 +01:00
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
``authors`` is a comma-separated list of article authors. If there's only one
|
|
|
|
|
|
author you can use ``author`` field.
|
2013-07-05 01:08:45 +02:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
If you do not explicitly specify summary metadata for a given post, the
|
|
|
|
|
|
``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the
|
|
|
|
|
|
beginning of an article are used as the summary.
|
2012-11-30 02:19:38 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
You can also extract any metadata from the filename through a regular
|
2013-04-16 19:45:46 -07:00
|
|
|
|
expression to be set in the ``FILENAME_METADATA`` setting. All named groups
|
|
|
|
|
|
that are matched will be set in the metadata object. The default value for the
|
|
|
|
|
|
``FILENAME_METADATA`` setting will only extract the date from the filename. For
|
|
|
|
|
|
example, if you would like to extract both the date and the slug, you could set
|
|
|
|
|
|
something like: ``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``
|
2012-11-30 02:19:38 +01:00
|
|
|
|
|
|
|
|
|
|
Please note that the metadata available inside your files takes precedence over
|
|
|
|
|
|
the metadata extracted from the filename.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
|
|
Pages
|
2014-05-12 07:48:37 -07:00
|
|
|
|
=====
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
If you create a folder named ``pages`` inside the content folder, all the
|
2013-04-14 15:04:38 -07:00
|
|
|
|
files in it will be used to generate static pages, such as **About** or
|
|
|
|
|
|
**Contact** pages. (See example filesystem layout below.)
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2013-04-14 15:04:38 -07:00
|
|
|
|
You can use the ``DISPLAY_PAGES_ON_MENU`` setting to control whether all those
|
|
|
|
|
|
pages are displayed in the primary navigation menu. (Default is ``True``.)
|
2010-12-20 22:50:54 +00:00
|
|
|
|
|
2012-06-26 19:26:43 -07:00
|
|
|
|
If you want to exclude any pages from being linked to or listed in the menu
|
2012-06-27 07:02:25 -07:00
|
|
|
|
then add a ``status: hidden`` attribute to its metadata. This is useful for
|
2012-06-26 19:26:43 -07:00
|
|
|
|
things like making error pages that fit the generated theme of your site.
|
|
|
|
|
|
|
2018-07-11 15:54:47 +02:00
|
|
|
|
Static content
|
|
|
|
|
|
==============
|
|
|
|
|
|
|
|
|
|
|
|
Static files are files other than articles and pages that are copied to the
|
|
|
|
|
|
output folder as-is, without processing. You can control which static files
|
|
|
|
|
|
are copied over with the ``STATIC_PATHS`` setting of the project's
|
|
|
|
|
|
``pelicanconf.py`` file. Pelican's default configuration includes the
|
|
|
|
|
|
``images`` directory for this, but others must be added manually. In addition,
|
|
|
|
|
|
static files that are explicitly linked to are included (see below).
|
|
|
|
|
|
|
2022-06-16 14:18:52 +10:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
|
|
In the default configuration, all files with a valid content file suffix
|
|
|
|
|
|
(``.html``, ``.rst``, ``.md``, ...) get processed by the article and page
|
|
|
|
|
|
generators *before* the static generator. This is avoided by altering the
|
|
|
|
|
|
``*_EXCLUDE`` settings appropriately.
|
|
|
|
|
|
|
2018-07-11 15:54:47 +02:00
|
|
|
|
Mixed content in the same directory
|
|
|
|
|
|
-----------------------------------
|
|
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
Starting with Pelican 3.5, static files can safely share a source directory
|
|
|
|
|
|
with page source files, without exposing the page sources in the generated
|
|
|
|
|
|
site. Any such directory must be added to both ``STATIC_PATHS`` and
|
|
|
|
|
|
``PAGE_PATHS`` (or ``STATIC_PATHS`` and ``ARTICLE_PATHS``). Pelican will
|
|
|
|
|
|
identify and process the page source files normally, and copy the remaining
|
|
|
|
|
|
files as if they lived in a separate directory reserved for static files.
|
2018-07-11 15:54:47 +02:00
|
|
|
|
|
|
|
|
|
|
Note: Placing static and content source files together in the same source
|
|
|
|
|
|
directory does not guarantee that they will end up in the same place in the
|
|
|
|
|
|
generated site. The easiest way to do this is by using the ``{attach}`` link
|
|
|
|
|
|
syntax (described below). Alternatively, the ``STATIC_SAVE_AS``,
|
|
|
|
|
|
``PAGE_SAVE_AS``, and ``ARTICLE_SAVE_AS`` settings (and the corresponding
|
|
|
|
|
|
``*_URL`` settings) can be configured to place files of different types
|
|
|
|
|
|
together, just as they could in earlier versions of Pelican.
|
|
|
|
|
|
|
2013-09-01 01:01:25 +05:00
|
|
|
|
.. _ref-linking-to-internal-content:
|
|
|
|
|
|
|
2012-12-01 21:35:15 +01:00
|
|
|
|
Linking to internal content
|
2014-05-12 07:48:37 -07:00
|
|
|
|
===========================
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
From Pelican 3.1 onwards, it is now possible to specify intra-site links to
|
|
|
|
|
|
files in the *source content* hierarchy instead of files in the *generated*
|
2014-10-31 17:21:15 -07:00
|
|
|
|
hierarchy. This makes it easier to link from the current post to other content
|
|
|
|
|
|
that may be sitting alongside that post (instead of having to determine where
|
|
|
|
|
|
the other content will be placed after site generation).
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2013-02-25 13:53:29 -05:00
|
|
|
|
To link to internal content (files in the ``content`` directory), use the
|
2014-10-31 17:21:15 -07:00
|
|
|
|
following syntax for the link target: ``{filename}path/to/file``
|
2015-01-02 23:45:44 -08:00
|
|
|
|
Note: forward slashes, ``/``,
|
|
|
|
|
|
are the required path separator in the ``{filename}`` directive
|
|
|
|
|
|
on all operating systems, including Windows.
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
For example, a Pelican project might be structured like this::
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
|
|
|
|
|
website/
|
|
|
|
|
|
├── content
|
2014-10-31 17:21:15 -07:00
|
|
|
|
│ ├── category/
|
|
|
|
|
|
│ │ └── article1.rst
|
|
|
|
|
|
│ ├── article2.md
|
2013-04-14 15:04:38 -07:00
|
|
|
|
│ └── pages
|
2013-04-16 19:45:46 -07:00
|
|
|
|
│ └── about.md
|
2012-12-01 21:35:15 +01:00
|
|
|
|
└── pelican.conf.py
|
|
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
In this example, ``article1.rst`` could look like this::
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2013-03-10 11:28:54 +05:00
|
|
|
|
The first article
|
|
|
|
|
|
#################
|
|
|
|
|
|
|
|
|
|
|
|
:date: 2012-12-01 10:02
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
See below intra-site link examples in reStructuredText format.
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
`a link relative to the current file <{filename}../article2.md>`_
|
|
|
|
|
|
`a link relative to the content root <{filename}/article2.md>`_
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
|
|
|
|
|
and ``article2.md``::
|
|
|
|
|
|
|
|
|
|
|
|
Title: The second article
|
2013-03-10 11:28:54 +05:00
|
|
|
|
Date: 2012-12-01 10:02
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
See below intra-site link examples in Markdown format.
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
[a link relative to the current file]({filename}category/article1.rst)
|
|
|
|
|
|
[a link relative to the content root]({filename}/category/article1.rst)
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
Linking to static files
|
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
2018-07-11 15:54:47 +02:00
|
|
|
|
You can link to static content using ``{static}path/to/file``. Files linked to
|
|
|
|
|
|
with this syntax will automatically be copied to the output directory, even if
|
|
|
|
|
|
the source directories containing them are not included in the ``STATIC_PATHS``
|
|
|
|
|
|
setting of the project's ``pelicanconf.py`` file.
|
2014-10-31 17:21:15 -07:00
|
|
|
|
|
|
|
|
|
|
For example, a project's content directory might be structured like this::
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2013-02-25 13:53:29 -05:00
|
|
|
|
content
|
|
|
|
|
|
├── images
|
|
|
|
|
|
│ └── han.jpg
|
2014-10-31 17:21:15 -07:00
|
|
|
|
├── pdfs
|
|
|
|
|
|
│ └── menu.pdf
|
|
|
|
|
|
└── pages
|
|
|
|
|
|
└── test.md
|
2013-02-25 13:53:29 -05:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
``test.md`` would include::
|
2013-02-25 13:53:29 -05:00
|
|
|
|
|
2018-07-11 15:54:47 +02:00
|
|
|
|

|
|
|
|
|
|
[Our Menu]({static}/pdfs/menu.pdf)
|
2013-02-25 13:53:29 -05:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
Site generation would then copy ``han.jpg`` to ``output/images/han.jpg``,
|
|
|
|
|
|
``menu.pdf`` to ``output/pdfs/menu.pdf``, and write the appropriate links
|
|
|
|
|
|
in ``test.md``.
|
|
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
If you use ``{static}`` to link to an article or a page, this will be turned
|
|
|
|
|
|
into a link to its source code.
|
2014-10-31 17:21:15 -07:00
|
|
|
|
|
|
|
|
|
|
Attaching static files
|
|
|
|
|
|
----------------------
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
Starting with Pelican 3.5, static files can be "attached" to a page or article
|
|
|
|
|
|
using this syntax for the link target: ``{attach}path/to/file`` This works
|
2018-07-11 15:54:47 +02:00
|
|
|
|
like the ``{static}`` syntax, but also relocates the static file into the
|
2014-10-31 17:21:15 -07:00
|
|
|
|
linking document's output directory. If the static file originates from a
|
|
|
|
|
|
subdirectory beneath the linking document's source, that relationship will be
|
|
|
|
|
|
preserved on output. Otherwise, it will become a sibling of the linking
|
|
|
|
|
|
document.
|
|
|
|
|
|
|
2018-07-11 15:54:47 +02:00
|
|
|
|
This only works for linking to static files.
|
2014-10-31 17:21:15 -07:00
|
|
|
|
|
|
|
|
|
|
For example, a project's content directory might be structured like this::
|
|
|
|
|
|
|
|
|
|
|
|
content
|
|
|
|
|
|
├── blog
|
|
|
|
|
|
│ ├── icons
|
|
|
|
|
|
│ │ └── icon.png
|
|
|
|
|
|
│ ├── photo.jpg
|
|
|
|
|
|
│ └── testpost.md
|
|
|
|
|
|
└── downloads
|
|
|
|
|
|
└── archive.zip
|
|
|
|
|
|
|
|
|
|
|
|
``pelicanconf.py`` would include::
|
|
|
|
|
|
|
|
|
|
|
|
PATH = 'content'
|
|
|
|
|
|
ARTICLE_PATHS = ['blog']
|
|
|
|
|
|
ARTICLE_SAVE_AS = '{date:%Y}/{slug}.html'
|
|
|
|
|
|
ARTICLE_URL = '{date:%Y}/{slug}.html'
|
|
|
|
|
|
|
|
|
|
|
|
``testpost.md`` would include::
|
|
|
|
|
|
|
|
|
|
|
|
Title: Test Post
|
|
|
|
|
|
Category: test
|
|
|
|
|
|
Date: 2014-10-31
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|

|
|
|
|
|
|
[Downloadable File]({attach}/downloads/archive.zip)
|
|
|
|
|
|
|
|
|
|
|
|
Site generation would then produce an output directory structured like this::
|
|
|
|
|
|
|
|
|
|
|
|
output
|
|
|
|
|
|
└── 2014
|
|
|
|
|
|
├── archive.zip
|
|
|
|
|
|
├── icons
|
|
|
|
|
|
│ └── icon.png
|
|
|
|
|
|
├── photo.jpg
|
|
|
|
|
|
└── test-post.html
|
|
|
|
|
|
|
|
|
|
|
|
Notice that all the files linked using ``{attach}`` ended up in or beneath
|
|
|
|
|
|
the article's output directory.
|
|
|
|
|
|
|
|
|
|
|
|
If a static file is linked multiple times, the relocating feature of
|
|
|
|
|
|
``{attach}`` will only work in the first of those links to be processed.
|
2018-07-11 15:54:47 +02:00
|
|
|
|
After the first link, Pelican will treat ``{attach}`` like ``{static}``.
|
2014-10-31 17:21:15 -07:00
|
|
|
|
This avoids breaking the already-processed links.
|
|
|
|
|
|
|
|
|
|
|
|
**Be careful when linking to a file from multiple documents:**
|
|
|
|
|
|
Since the first link to a file finalizes its location and Pelican does
|
|
|
|
|
|
not define the order in which documents are processed, using ``{attach}`` on a
|
|
|
|
|
|
file linked by multiple documents can cause its location to change from one
|
|
|
|
|
|
site build to the next. (Whether this happens in practice will depend on the
|
|
|
|
|
|
operating system, file system, version of Pelican, and documents being added,
|
|
|
|
|
|
modified, or removed from the project.) Any external sites linking to the
|
|
|
|
|
|
file's old location might then find their links broken. **It is therefore
|
|
|
|
|
|
advisable to use {attach} only if you use it in all links to a file, and only
|
|
|
|
|
|
if the linking documents share a single directory.** Under these conditions,
|
|
|
|
|
|
the file's output location will not change in future builds. In cases where
|
2018-07-11 15:54:47 +02:00
|
|
|
|
these precautions are not possible, consider using ``{static}`` links instead
|
2014-10-31 17:21:15 -07:00
|
|
|
|
of ``{attach}``, and letting the file's location be determined by the project's
|
|
|
|
|
|
``STATIC_SAVE_AS`` and ``STATIC_URL`` settings. (Per-file ``save_as`` and
|
|
|
|
|
|
``url`` overrides can still be set in ``EXTRA_PATH_METADATA``.)
|
|
|
|
|
|
|
2020-04-15 01:35:04 -07:00
|
|
|
|
.. note::
|
|
|
|
|
|
When using ``{attach}``, any parent directory in ``*_URL`` / ``*_SAVE_AS``
|
|
|
|
|
|
settings should match each other. See also: :ref:`url-settings`
|
|
|
|
|
|
|
2015-09-15 02:24:21 +03:00
|
|
|
|
Linking to authors, categories, index and tags
|
|
|
|
|
|
----------------------------------------------
|
2014-10-31 17:21:15 -07:00
|
|
|
|
|
2015-09-15 02:24:21 +03:00
|
|
|
|
You can link to authors, categories, index and tags using the ``{author}name``,
|
|
|
|
|
|
``{category}foobar``, ``{index}`` and ``{tag}tagname`` syntax.
|
2013-08-17 17:36:13 +02:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
Deprecated internal link syntax
|
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
To remain compatible with earlier versions, Pelican still supports vertical
|
|
|
|
|
|
bars (``||``) in addition to curly braces (``{}``) for internal links. For
|
|
|
|
|
|
example: ``|filename|an_article.rst``, ``|tag|tagname``, ``|category|foobar``.
|
2014-10-31 17:21:15 -07:00
|
|
|
|
The syntax was changed from ``||`` to ``{}`` to avoid collision with Markdown
|
2018-11-02 20:53:15 -06:00
|
|
|
|
extensions or reST directives. Similarly, Pelican also still supports linking
|
|
|
|
|
|
to static content with ``{filename}``. The syntax was changed to ``{static}``
|
|
|
|
|
|
to allow linking to both generated articles and pages and their static sources.
|
2018-07-11 15:54:47 +02:00
|
|
|
|
|
|
|
|
|
|
Support for the old syntax may eventually be removed.
|
2014-10-31 17:21:15 -07:00
|
|
|
|
|
2019-10-17 13:06:28 +02:00
|
|
|
|
Including other files
|
|
|
|
|
|
---------------------
|
|
|
|
|
|
Both Markdown and reStructuredText syntaxes provide mechanisms for this.
|
|
|
|
|
|
|
|
|
|
|
|
Following below are some examples for **reStructuredText** using `the include directive`_:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: rst
|
|
|
|
|
|
|
|
|
|
|
|
.. include:: file.rst
|
|
|
|
|
|
|
|
|
|
|
|
Include a fragment of a file delimited by two identifiers, highlighted as C++ (slicing based on line numbers is also possible):
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: rst
|
|
|
|
|
|
|
|
|
|
|
|
.. include:: main.cpp
|
|
|
|
|
|
:code: c++
|
|
|
|
|
|
:start-after: // begin
|
|
|
|
|
|
:end-before: // end
|
|
|
|
|
|
|
|
|
|
|
|
Include a raw HTML file (or an inline SVG) and put it directly into the output without any processing:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: rst
|
|
|
|
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
:file: table.html
|
|
|
|
|
|
|
|
|
|
|
|
For **Markdown**, one must rely on an extension. For example, using the `mdx_include plugin`_:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
|
{! template.html !}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2013-08-17 17:36:13 +02:00
|
|
|
|
|
2014-05-12 07:48:37 -07:00
|
|
|
|
Importing an existing site
|
|
|
|
|
|
==========================
|
2011-06-17 19:26:28 +02:00
|
|
|
|
|
2014-05-12 07:48:37 -07:00
|
|
|
|
It is possible to import your site from WordPress, Tumblr, Dotclear, and RSS
|
|
|
|
|
|
feeds using a simple script. See :ref:`import`.
|
2011-06-17 19:26:28 +02:00
|
|
|
|
|
2010-12-20 22:50:54 +00:00
|
|
|
|
Translations
|
2014-05-12 07:48:37 -07:00
|
|
|
|
============
|
2010-12-20 22:50:54 +00:00
|
|
|
|
|
2012-07-01 10:52:39 -07:00
|
|
|
|
It is possible to translate articles. To do so, you need to add a ``lang`` meta
|
|
|
|
|
|
attribute to your articles/pages and set a ``DEFAULT_LANG`` setting (which is
|
2012-03-06 06:13:17 -08:00
|
|
|
|
English [en] by default). With those settings in place, only articles with the
|
|
|
|
|
|
default language will be listed, and each article will be accompanied by a list
|
|
|
|
|
|
of available translations for that article.
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
2014-11-04 16:47:52 +01:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
|
|
This core Pelican functionality does not create sub-sites
|
|
|
|
|
|
(e.g. ``example.com/de``) with translated templates for each
|
|
|
|
|
|
language. For such advanced functionality the `i18n_subsites
|
|
|
|
|
|
plugin`_ can be used.
|
|
|
|
|
|
|
2018-03-22 23:47:51 +01:00
|
|
|
|
By default, Pelican uses the article's URL "slug" to determine if two or more
|
|
|
|
|
|
articles are translations of one another. (This can be changed with the
|
|
|
|
|
|
``ARTICLE_TRANSLATION_ID`` setting.) The slug can be set manually in the file's
|
2012-03-06 06:13:17 -08:00
|
|
|
|
metadata; if not set explicitly, Pelican will auto-generate the slug from the
|
|
|
|
|
|
title of the article.
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Here is an example of two articles, one in English and the other in French.
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
The English article::
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
|
|
|
|
|
Foobar is not dead
|
|
|
|
|
|
##################
|
|
|
|
|
|
|
|
|
|
|
|
:slug: foobar-is-not-dead
|
|
|
|
|
|
:lang: en
|
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
That's true, foobar is still alive!
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
And the French version::
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
|
|
|
|
|
Foobar n'est pas mort !
|
|
|
|
|
|
#######################
|
|
|
|
|
|
|
|
|
|
|
|
:slug: foobar-is-not-dead
|
|
|
|
|
|
:lang: fr
|
|
|
|
|
|
|
|
|
|
|
|
Oui oui, foobar est toujours vivant !
|
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Post content quality notwithstanding, you can see that only item in common
|
|
|
|
|
|
between the two articles is the slug, which is functioning here as an
|
|
|
|
|
|
identifier. If you'd rather not explicitly define the slug this way, you must
|
|
|
|
|
|
then instead ensure that the translated article titles are identical, since the
|
|
|
|
|
|
slug will be auto-generated from the article title.
|
2011-01-12 23:45:06 +01:00
|
|
|
|
|
2013-04-06 17:48:19 +01:00
|
|
|
|
If you do not want the original version of one specific article to be detected
|
|
|
|
|
|
by the ``DEFAULT_LANG`` setting, use the ``translation`` metadata to specify
|
|
|
|
|
|
which posts are translations::
|
|
|
|
|
|
|
|
|
|
|
|
Foobar is not dead
|
|
|
|
|
|
##################
|
|
|
|
|
|
|
|
|
|
|
|
:slug: foobar-is-not-dead
|
|
|
|
|
|
:lang: en
|
|
|
|
|
|
:translation: true
|
|
|
|
|
|
|
|
|
|
|
|
That's true, foobar is still alive!
|
|
|
|
|
|
|
2013-09-15 22:43:24 -07:00
|
|
|
|
|
|
|
|
|
|
.. _internal_pygments_options:
|
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Syntax highlighting
|
2014-05-12 07:48:37 -07:00
|
|
|
|
===================
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
Pelican can provide colorized syntax highlighting for your code blocks.
|
|
|
|
|
|
To do so, you must use the following conventions inside your content files.
|
2012-04-01 13:54:20 +02:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
For reStructuredText, use the ``code-block`` directive to specify the type
|
|
|
|
|
|
of code to be highlighted (in these examples, we'll use ``python``)::
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
.. code-block:: python
|
2011-06-03 18:26:27 +02:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
print("Pelican is a static site generator.")
|
|
|
|
|
|
|
|
|
|
|
|
For Markdown, which utilizes the `CodeHilite extension`_ to provide syntax
|
|
|
|
|
|
highlighting, include the language identifier just above the code block,
|
|
|
|
|
|
indenting both the identifier and the code::
|
|
|
|
|
|
|
|
|
|
|
|
There are two ways to specify the identifier:
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
:::python
|
|
|
|
|
|
print("The triple-colon syntax will *not* show line numbers.")
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
To display line numbers, use a path-less shebang instead of colons:
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2015-06-26 09:44:45 -07:00
|
|
|
|
#!python
|
|
|
|
|
|
print("The path-less shebang syntax *will* show line numbers.")
|
2012-03-06 06:13:17 -08:00
|
|
|
|
|
2012-09-10 20:48:13 -07:00
|
|
|
|
The specified identifier (e.g. ``python``, ``ruby``) should be one that
|
2020-04-12 09:38:35 -05:00
|
|
|
|
appears on the `list of available lexers <https://pygments.org/docs/lexers/>`_.
|
2012-03-06 06:13:17 -08:00
|
|
|
|
|
2013-09-15 22:43:24 -07:00
|
|
|
|
When using reStructuredText the following options are available in the
|
|
|
|
|
|
code-block directive:
|
|
|
|
|
|
|
|
|
|
|
|
============= ============ =========================================
|
|
|
|
|
|
Option Valid values Description
|
|
|
|
|
|
============= ============ =========================================
|
|
|
|
|
|
anchorlinenos N/A If present wrap line numbers in <a> tags.
|
|
|
|
|
|
classprefix string String to prepend to token class names
|
2016-08-14 11:52:21 -07:00
|
|
|
|
hl_lines numbers List of lines to be highlighted, where
|
|
|
|
|
|
line numbers to highlight are separated
|
|
|
|
|
|
by a space. This is similar to
|
|
|
|
|
|
``emphasize-lines`` in Sphinx, but it
|
|
|
|
|
|
does not support a range of line numbers
|
|
|
|
|
|
separated by a hyphen, or comma-separated
|
|
|
|
|
|
line numbers.
|
2013-09-15 22:43:24 -07:00
|
|
|
|
lineanchors string Wrap each line in an anchor using this
|
|
|
|
|
|
string and -linenumber.
|
2013-07-05 01:08:45 +02:00
|
|
|
|
linenos string If present or set to "table" output line
|
2013-09-15 22:43:24 -07:00
|
|
|
|
numbers in a table, if set to
|
|
|
|
|
|
"inline" output them inline. "none" means
|
2013-07-05 01:08:45 +02:00
|
|
|
|
do not output the line numbers for this
|
2013-09-15 22:43:24 -07:00
|
|
|
|
table.
|
2013-07-05 01:08:45 +02:00
|
|
|
|
linenospecial number If set every nth line will be given the
|
2013-09-15 22:43:24 -07:00
|
|
|
|
'special' css class.
|
|
|
|
|
|
linenostart number Line number for the first line.
|
|
|
|
|
|
linenostep number Print every nth line number.
|
|
|
|
|
|
lineseparator string String to print between lines of code,
|
|
|
|
|
|
'\n' by default.
|
|
|
|
|
|
linespans string Wrap each line in a span using this and
|
|
|
|
|
|
-linenumber.
|
|
|
|
|
|
nobackground N/A If set do not output background color for
|
|
|
|
|
|
the wrapping element
|
|
|
|
|
|
nowrap N/A If set do not wrap the tokens at all.
|
|
|
|
|
|
tagsfile string ctags file to use for name definitions.
|
|
|
|
|
|
tagurlformat string format for the ctag links.
|
|
|
|
|
|
============= ============ =========================================
|
|
|
|
|
|
|
2013-09-23 19:30:51 +02:00
|
|
|
|
Note that, depending on the version, your Pygments module might not have
|
|
|
|
|
|
all of these options available. Refer to the *HtmlFormatter* section of the
|
2020-04-12 09:38:35 -05:00
|
|
|
|
`Pygments documentation <https://pygments.org/docs/formatters/>`_ for more
|
2013-09-15 22:43:24 -07:00
|
|
|
|
details on each of the options.
|
|
|
|
|
|
|
2013-09-23 19:30:51 +02:00
|
|
|
|
For example, the following code block enables line numbers, starting at 153,
|
2013-09-15 22:43:24 -07:00
|
|
|
|
and prefixes the Pygments CSS classes with *pgcss* to make the names
|
|
|
|
|
|
more unique and avoid possible CSS conflicts::
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: identifier
|
|
|
|
|
|
:classprefix: pgcss
|
|
|
|
|
|
:linenos: table
|
|
|
|
|
|
:linenostart: 153
|
|
|
|
|
|
|
|
|
|
|
|
<indented code block goes here>
|
|
|
|
|
|
|
2013-09-23 19:30:51 +02:00
|
|
|
|
It is also possible to specify the ``PYGMENTS_RST_OPTIONS`` variable in your
|
|
|
|
|
|
Pelican settings file to include options that will be automatically applied to
|
|
|
|
|
|
every code block.
|
2013-09-15 22:43:24 -07:00
|
|
|
|
|
2013-09-23 19:30:51 +02:00
|
|
|
|
For example, if you want to have line numbers displayed for every code block
|
2013-09-15 22:43:24 -07:00
|
|
|
|
and a CSS prefix you would set this variable to::
|
|
|
|
|
|
|
2013-09-23 19:30:51 +02:00
|
|
|
|
PYGMENTS_RST_OPTIONS = {'classprefix': 'pgcss', 'linenos': 'table'}
|
2013-09-15 22:43:24 -07:00
|
|
|
|
|
2013-09-23 19:30:51 +02:00
|
|
|
|
If specified, settings for individual code blocks will override the defaults in
|
|
|
|
|
|
your settings file.
|
2013-09-15 22:43:24 -07:00
|
|
|
|
|
2011-05-08 14:58:57 +01:00
|
|
|
|
Publishing drafts
|
2014-05-12 07:48:37 -07:00
|
|
|
|
=================
|
2011-05-08 14:58:57 +01:00
|
|
|
|
|
2018-07-03 12:08:27 +02:00
|
|
|
|
If you want to publish an article or a page as a draft (for friends to review
|
|
|
|
|
|
before publishing, for example), you can add a ``Status: draft`` attribute to
|
|
|
|
|
|
its metadata. That article will then be output to the ``drafts`` folder and not
|
2013-09-23 19:30:51 +02:00
|
|
|
|
listed on the index page nor on any category or tag page.
|
2011-08-17 10:38:48 +02:00
|
|
|
|
|
2018-11-02 20:53:15 -06:00
|
|
|
|
If your articles should be automatically published as a draft (to not
|
|
|
|
|
|
accidentally publish an article before it is finished) include the status in
|
|
|
|
|
|
the ``DEFAULT_METADATA``::
|
2014-11-18 13:37:27 +00:00
|
|
|
|
|
|
|
|
|
|
DEFAULT_METADATA = {
|
2015-01-05 12:22:00 +01:00
|
|
|
|
'status': 'draft',
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-02-01 16:42:51 -05:00
|
|
|
|
To publish a post when the default status is ``draft``, update the post's
|
|
|
|
|
|
metadata to include ``Status: published``.
|
|
|
|
|
|
|
2021-04-16 19:07:35 -05:00
|
|
|
|
Hidden Posts
|
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
|
|
Like pages, posts can also be marked as ``hidden`` with the ``Status: hidden``
|
|
|
|
|
|
attribute. Hidden posts will be output to ``ARTICLE_SAVE_AS`` as expected, but
|
2022-09-13 15:30:43 +03:00
|
|
|
|
are not included by default in tag, category, and author indexes, nor in the
|
|
|
|
|
|
main article feed. This has the effect of creating an "unlisted" post.
|
2021-04-16 19:07:35 -05:00
|
|
|
|
|
2019-04-25 15:08:04 +02:00
|
|
|
|
.. _W3C ISO 8601: https://www.w3.org/TR/NOTE-datetime
|
2020-04-12 09:38:35 -05:00
|
|
|
|
.. _AsciiDoc: https://www.methods.co.nz/asciidoc/
|
2019-04-25 15:08:04 +02:00
|
|
|
|
.. _pelican-plugins: https://github.com/getpelican/pelican-plugins
|
2020-05-17 06:26:30 +02:00
|
|
|
|
.. _Python-Markdown: https://github.com/Python-Markdown/markdown
|
2018-03-12 14:35:40 +01:00
|
|
|
|
.. _Markdown Extensions: https://python-markdown.github.io/extensions/
|
|
|
|
|
|
.. _CodeHilite extension: https://python-markdown.github.io/extensions/code_hilite/#syntax
|
2019-04-25 15:08:04 +02:00
|
|
|
|
.. _i18n_subsites plugin: https://github.com/getpelican/pelican-plugins/tree/master/i18n_subsites
|
2019-10-17 13:06:28 +02:00
|
|
|
|
.. _the include directive: http://docutils.sourceforge.net/docs/ref/rst/directives.html#include
|
|
|
|
|
|
.. _mdx_include plugin: https://github.com/neurobin/mdx_include
|