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
|
|
|
|
|
2016-10-22 15:00:52 -06:00
|
|
|
|
You can find sample content in the repository at: ``pelican/samples/content/``
|
|
|
|
|
|
|
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)`.
|
|
|
|
|
|
|
2013-04-17 21:14:52 -07: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 ``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
|
|
|
|
|
|
be configured and loaded via the ``MD_EXTENSIONS`` setting.
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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>
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07: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
|
|
|
|
|
|
interchangeably.
|
2012-07-09 22:43:51 -04:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Note that, aside from the title, none of this article 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`__.
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-11-05 19:38:58 +01: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-07-05 01:08:45 +02:00
|
|
|
|
``authors`` is a comma-separated list of article authors. If there's only one author you
|
|
|
|
|
|
can use ``author`` field.
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
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
|
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
|
|
Linking to non-article or non-page content uses the same ``{filename}`` syntax
|
|
|
|
|
|
as described above. It is important to remember that those files will not be
|
|
|
|
|
|
copied to the output directory unless the source directories containing them
|
|
|
|
|
|
are included in 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. Forgetting to do so will result in
|
|
|
|
|
|
broken links.
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-08-29 23:23:54 +05:00
|
|
|
|

|
2014-10-31 17:21:15 -07:00
|
|
|
|
[Our Menu]({filename}/pdfs/menu.pdf)
|
2013-02-25 13:53:29 -05:00
|
|
|
|
|
2014-10-31 17:21:15 -07:00
|
|
|
|
``pelicanconf.py`` would include::
|
2013-02-25 13:53:29 -05:00
|
|
|
|
|
|
|
|
|
|
STATIC_PATHS = ['images', 'pdfs']
|
|
|
|
|
|
|
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``.
|
|
|
|
|
|
|
|
|
|
|
|
Mixed content in the same directory
|
|
|
|
|
|
-----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
like the ``{filename}`` syntax, but also relocates the static file into the
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
This only works for linking to static files, and only when they originate from
|
|
|
|
|
|
a directory included in the ``STATIC_PATHS`` setting.
|
|
|
|
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
|
STATIC_PATHS = ['blog', 'downloads']
|
|
|
|
|
|
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.
|
|
|
|
|
|
After the first link, Pelican will treat ``{attach}`` like ``{filename}``.
|
|
|
|
|
|
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
|
|
|
|
|
|
these precautions are not possible, consider using ``{filename}`` links instead
|
|
|
|
|
|
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``.)
|
|
|
|
|
|
|
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
|
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
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``.
|
|
|
|
|
|
The syntax was changed from ``||`` to ``{}`` to avoid collision with Markdown
|
|
|
|
|
|
extensions or reST directives. Support for the old syntax may eventually be
|
|
|
|
|
|
removed.
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Pelican uses the article's URL "slug" to determine if two or more articles are
|
|
|
|
|
|
translations of one another. The slug can be set manually in the file's
|
|
|
|
|
|
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
|
2012-08-23 18:31:45 -07:00
|
|
|
|
appears on the `list of available lexers <http://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
|
|
|
|
|
|
`Pygments documentation <http://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
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
If you want to publish an article as a draft (for friends to review before
|
2013-09-23 19:30:51 +02:00
|
|
|
|
publishing, for example), you can add a ``Status: draft`` attribute to its
|
2012-03-06 06:13:17 -08:00
|
|
|
|
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
|
|
|
|
|
2014-11-18 13:37:27 +00: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``::
|
|
|
|
|
|
|
|
|
|
|
|
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``.
|
|
|
|
|
|
|
2013-06-11 21:40:13 -04:00
|
|
|
|
.. _W3C ISO 8601: http://www.w3.org/TR/NOTE-datetime
|
2013-08-07 12:45:26 -07:00
|
|
|
|
.. _AsciiDoc: http://www.methods.co.nz/asciidoc/
|
2014-06-10 18:05:29 -04:00
|
|
|
|
.. _pelican-plugins: http://github.com/getpelican/pelican-plugins
|
2014-11-02 22:24:29 +01:00
|
|
|
|
.. _Markdown Extensions: http://pythonhosted.org/Markdown/extensions/
|
2015-06-26 09:44:45 -07:00
|
|
|
|
.. _CodeHilite extension: http://pythonhosted.org/Markdown/extensions/code_hilite.html#syntax
|
2014-11-04 16:47:52 +01:00
|
|
|
|
.. _i18n_subsites plugin: http://github.com/getpelican/pelican-plugins/tree/master/i18n_subsites
|