Docs: Reflow to 79 char line limit

This commit is contained in:
MinchinWeb 2018-11-02 20:53:15 -06:00
commit f595741b8e
16 changed files with 481 additions and 460 deletions

View file

@ -12,8 +12,9 @@ Next release
``'bar'`` from ``'foo/bar.html'`` (unless ``'bar' == 'index'``). ``'bar'`` from ``'foo/bar.html'`` (unless ``'bar' == 'index'``).
* ``ARTICLE_ORDER_BY`` and ``PAGE_ORDER_BY`` now also affect 1) category, tag * ``ARTICLE_ORDER_BY`` and ``PAGE_ORDER_BY`` now also affect 1) category, tag
and author pages 2) feeds 3) draft and hidden articles and pages and author pages 2) feeds 3) draft and hidden articles and pages
* New ``ARTICLE_TRANSLATION_ID`` and ``PAGE_TRANSLATION_ID`` settings to specify * New ``ARTICLE_TRANSLATION_ID`` and ``PAGE_TRANSLATION_ID`` settings to
metadata attributes used to identify translations; or to disable translations specify metadata attributes used to identify translations; or to disable
translations
* New ``{static}`` syntax to link to static content; content linked to by * New ``{static}`` syntax to link to static content; content linked to by
``{static}`` and ``{attach}`` is automatically copied over even if not in ``{static}`` and ``{attach}`` is automatically copied over even if not in
``STATIC_PATHS`` ``STATIC_PATHS``
@ -103,8 +104,8 @@ Next release
directory as articles and pages using ``{attach}`` in the path. directory as articles and pages using ``{attach}`` in the path.
* Prevent Pelican from raising an exception when there are duplicate pieces of * Prevent Pelican from raising an exception when there are duplicate pieces of
metadata in a Markdown file. metadata in a Markdown file.
* Introduce the ``TYPOGRIFY_IGNORE_TAGS`` setting to add HTML tags to be ignored * Introduce the ``TYPOGRIFY_IGNORE_TAGS`` setting to add HTML tags to be
by Typogrify. ignored by Typogrify.
* Add the ability to use ``-`` in date formats to strip leading zeros. For * Add the ability to use ``-`` in date formats to strip leading zeros. For
example, ``%-d/%-m/%y`` will now result in the date ``9/8/12``. example, ``%-d/%-m/%y`` will now result in the date ``9/8/12``.
* Ensure feed generation is correctly disabled during quickstart configuration. * Ensure feed generation is correctly disabled during quickstart configuration.
@ -207,8 +208,10 @@ Next release
* Improve appearance of LinkedIn icon in default theme * Improve appearance of LinkedIn icon in default theme
* Add GitHub and Google+ social icons support in default theme * Add GitHub and Google+ social icons support in default theme
* Optimize social icons * Optimize social icons
* Add ``FEED_ALL_ATOM`` and ``FEED_ALL_RSS`` to generate feeds containing all posts regardless of their language * Add ``FEED_ALL_ATOM`` and ``FEED_ALL_RSS`` to generate feeds containing all
* Split ``TRANSLATION_FEED`` into ``TRANSLATION_FEED_ATOM`` and ``TRANSLATION_FEED_RSS`` posts regardless of their language
* Split ``TRANSLATION_FEED`` into ``TRANSLATION_FEED_ATOM`` and
``TRANSLATION_FEED_RSS``
* Different feeds can now be enabled/disabled individually * Different feeds can now be enabled/disabled individually
* Allow for blank author: if ``AUTHOR`` setting is not set, author won't * Allow for blank author: if ``AUTHOR`` setting is not set, author won't
default to ``${USER}`` anymore, and a post won't contain any author default to ``${USER}`` anymore, and a post won't contain any author
@ -216,7 +219,8 @@ Next release
* Move LESS and Webassets support from Pelican core to plugin * Move LESS and Webassets support from Pelican core to plugin
* The ``DEFAULT_DATE`` setting now defaults to ``None``, which means that * The ``DEFAULT_DATE`` setting now defaults to ``None``, which means that
articles won't be generated unless date metadata is specified articles won't be generated unless date metadata is specified
* Add ``FILENAME_METADATA`` setting to support metadata extraction from filename * Add ``FILENAME_METADATA`` setting to support metadata extraction from
filename
* Add ``gzip_cache`` plugin to compress common text files into a ``.gz`` * Add ``gzip_cache`` plugin to compress common text files into a ``.gz``
file within the same directory as the original file, preventing the server file within the same directory as the original file, preventing the server
(e.g. Nginx) from having to compress files during an HTTP call (e.g. Nginx) from having to compress files during an HTTP call
@ -287,7 +291,8 @@ Next release
* Added translations * Added translations
* Added a way to use cleaner URLs with a rewrite url module (or equivalent) * Added a way to use cleaner URLs with a rewrite url module (or equivalent)
* Added a tag cloud * Added a tag cloud
* Added an autoreloading feature: the blog is automatically regenerated each time a modification is detected * Added an autoreloading feature: the blog is automatically regenerated each
time a modification is detected
* Translate the documentation into French * Translate the documentation into French
* Import a blog from an RSS feed * Import a blog from an RSS feed
* Pagination support * Pagination support

View file

@ -70,7 +70,9 @@ Metadata syntax for Markdown posts should follow this pattern::
This is the content of my super blog post. This is the content of my super blog post.
You can also have your own metadata keys (so long as they don't conflict with reserved metadata keywords) for use in your python templates. The following is the list of reserved metadata keywords: You can also have your own metadata keys (so long as they don't conflict with
reserved metadata keywords) for use in your python templates. The following is
the list of reserved metadata keywords:
* `Title` * `Title`
* `Tags` * `Tags`
@ -133,12 +135,13 @@ the W3C's `suggested subset ISO 8601`__.
__ `W3C ISO 8601`_ __ `W3C ISO 8601`_
``modified`` should be last time you updated the article, and defaults to ``date`` if not specified. ``modified`` should be last time you updated the article, and defaults to
Besides you can show ``modified`` in the templates, feed entries in feed readers will be updated automatically ``date`` if not specified. Besides you can show ``modified`` in the templates,
when you set ``modified`` to the current date after you modified your article. feed entries in feed readers will be updated automatically when you set
``modified`` to the current date after you modified your article.
``authors`` is a comma-separated list of article authors. If there's only one author you ``authors`` is a comma-separated list of article authors. If there's only one
can use ``author`` field. author you can use ``author`` field.
If you do not explicitly specify summary metadata for a given post, the 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 ``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the
@ -181,12 +184,12 @@ static files that are explicitly linked to are included (see below).
Mixed content in the same directory Mixed content in the same directory
----------------------------------- -----------------------------------
Starting with Pelican 3.5, static files can safely share a source directory with Starting with Pelican 3.5, static files can safely share a source directory
page source files, without exposing the page sources in the generated site. with page source files, without exposing the page sources in the generated
Any such directory must be added to both ``STATIC_PATHS`` and ``PAGE_PATHS`` site. Any such directory must be added to both ``STATIC_PATHS`` and
(or ``STATIC_PATHS`` and ``ARTICLE_PATHS``). Pelican will identify and process ``PAGE_PATHS`` (or ``STATIC_PATHS`` and ``ARTICLE_PATHS``). Pelican will
the page source files normally, and copy the remaining files as if they lived identify and process the page source files normally, and copy the remaining
in a separate directory reserved for static files. 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 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 directory does not guarantee that they will end up in the same place in the
@ -273,8 +276,8 @@ Site generation would then copy ``han.jpg`` to ``output/images/han.jpg``,
``menu.pdf`` to ``output/pdfs/menu.pdf``, and write the appropriate links ``menu.pdf`` to ``output/pdfs/menu.pdf``, and write the appropriate links
in ``test.md``. in ``test.md``.
If you use ``{static}`` to link to an article or a page, this will be turned into If you use ``{static}`` to link to an article or a page, this will be turned
a link to its source code. into a link to its source code.
Attaching static files Attaching static files
---------------------- ----------------------
@ -360,13 +363,13 @@ You can link to authors, categories, index and tags using the ``{author}name``,
Deprecated internal link syntax Deprecated internal link syntax
------------------------------- -------------------------------
To remain compatible with earlier versions, Pelican still supports vertical bars To remain compatible with earlier versions, Pelican still supports vertical
(``||``) in addition to curly braces (``{}``) for internal links. For example: bars (``||``) in addition to curly braces (``{}``) for internal links. For
``|filename|an_article.rst``, ``|tag|tagname``, ``|category|foobar``. example: ``|filename|an_article.rst``, ``|tag|tagname``, ``|category|foobar``.
The syntax was changed from ``||`` to ``{}`` to avoid collision with Markdown The syntax was changed from ``||`` to ``{}`` to avoid collision with Markdown
extensions or reST directives. Similarly, Pelican also still supports linking to extensions or reST directives. Similarly, Pelican also still supports linking
static content with ``{filename}``. The syntax was changed to ``{static}`` to allow to static content with ``{filename}``. The syntax was changed to ``{static}``
linking to both generated articles and pages and their static sources. to allow linking to both generated articles and pages and their static sources.
Support for the old syntax may eventually be removed. Support for the old syntax may eventually be removed.
@ -546,8 +549,9 @@ 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 its metadata. That article will then be output to the ``drafts`` folder and not
listed on the index page nor on any category or tag page. listed on the index page nor on any category or tag page.
If your articles should be automatically published as a draft (to not accidentally If your articles should be automatically published as a draft (to not
publish an article before it is finished) include the status in the ``DEFAULT_METADATA``:: accidentally publish an article before it is finished) include the status in
the ``DEFAULT_METADATA``::
DEFAULT_METADATA = { DEFAULT_METADATA = {
'status': 'draft', 'status': 'draft',

View file

@ -66,9 +66,8 @@ Open ``_build/html/index.html`` in your browser to preview the documentation.
Running the test suite Running the test suite
====================== ======================
Each time you add a feature, there are two things to do regarding tests: Each time you add a feature, there are two things to do regarding tests: check
check that the existing tests pass, and add tests for the new feature that the existing tests pass, and add tests for the new feature or bugfix.
or bugfix.
The tests live in ``pelican/tests`` and you can run them using the The tests live in ``pelican/tests`` and you can run them using the
"discover" feature of ``unittest``:: "discover" feature of ``unittest``::
@ -92,8 +91,8 @@ functional tests. To do so, **make sure you have both** ``en_EN.utf8`` **and**
You may also find that some tests are skipped because some dependency (e.g., You may also find that some tests are skipped because some dependency (e.g.,
Pandoc) is not installed. This does not automatically mean that these tests Pandoc) is not installed. This does not automatically mean that these tests
have passed; you should at least verify that any skipped tests are not have passed; you should at least verify that any skipped tests are not affected
affected by your changes. by your changes.
You should run the test suite under each of the supported versions of Python. You should run the test suite under each of the supported versions of Python.
This is best done by creating a separate Python environment for each version. This is best done by creating a separate Python environment for each version.
@ -178,9 +177,9 @@ Optionally, you can also set ``'limit_args'`` as a tuple of arguments in
``extra`` dict if your generic message needs formatting. ``extra`` dict if your generic message needs formatting.
Limit is set to ``5``, i.e, first four logs with the same ``'limit_msg'`` are Limit is set to ``5``, i.e, first four logs with the same ``'limit_msg'`` are
outputted normally but the fifth one will be logged using outputted normally but the fifth one will be logged using ``'limit_msg'`` (and
``'limit_msg'`` (and ``'limit_args'`` if present). After the fifth, ``'limit_args'`` if present). After the fifth, corresponding log messages will
corresponding log messages will be ignored. be ignored.
For example, if you want to log missing resources, use the following code:: For example, if you want to log missing resources, use the following code::

View file

@ -12,10 +12,10 @@ How can I help?
=============== ===============
There are several ways to help out. First, you can report any Pelican There are several ways to help out. First, you can report any Pelican
suggestions or problems you might have via IRC (preferred) or the suggestions or problems you might have via IRC (preferred) or the `issue
`issue tracker <https://github.com/getpelican/pelican/issues>`_. If submitting tracker <https://github.com/getpelican/pelican/issues>`_. If submitting an
an issue report, please first check the existing issue list (both open and issue report, please first check the existing issue list (both open and closed)
closed) in order to avoid submitting a duplicate issue. in order to avoid submitting a duplicate issue.
If you want to contribute, please fork `the git repository If you want to contribute, please fork `the git repository
<https://github.com/getpelican/pelican/>`_, create a new feature branch, make <https://github.com/getpelican/pelican/>`_, create a new feature branch, make
@ -35,10 +35,10 @@ via the command line. See ``pelican --help`` for more information.
Changes to the settings file take no effect Changes to the settings file take no effect
=========================================== ===========================================
When experimenting with different settings (especially the metadata When experimenting with different settings (especially the metadata ones)
ones) caching may interfere and the changes may not be visible. In caching may interfere and the changes may not be visible. In such cases, ensure
such cases, ensure that caching is disabled via ``LOAD_CONTENT_CACHE = False`` that caching is disabled via ``LOAD_CONTENT_CACHE = False`` or use the
or use the ``--ignore-cache`` command-line switch. ``--ignore-cache`` command-line switch.
I'm creating my own theme. How do I use Pygments for syntax highlighting? I'm creating my own theme. How do I use Pygments for syntax highlighting?
========================================================================= =========================================================================
@ -70,9 +70,9 @@ I want to use Markdown, but I got an error.
If you try to generate Markdown content without first installing the Markdown If you try to generate Markdown content without first installing the Markdown
library, may see a message that says ``No valid files found in content``. library, may see a message that says ``No valid files found in content``.
Markdown is not a hard dependency for Pelican, so if you have content in Markdown is not a hard dependency for Pelican, so if you have content in
Markdown format, you will need to explicitly install the Markdown library. Markdown format, you will need to explicitly install the Markdown library. You
You can do so by typing the following command, prepending ``sudo`` if can do so by typing the following command, prepending ``sudo`` if permissions
permissions require it:: require it::
pip install markdown pip install markdown
@ -150,9 +150,9 @@ the ``'index'`` direct template.
What if I want to disable feed generation? What if I want to disable feed generation?
========================================== ==========================================
To disable feed generation, all feed settings should be set to ``None``. To disable feed generation, all feed settings should be set to ``None``. All
All but three feed settings already default to ``None``, so if you want to but three feed settings already default to ``None``, so if you want to disable
disable all feed generation, you only need to specify the following settings:: all feed generation, you only need to specify the following settings::
FEED_ALL_ATOM = None FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None CATEGORY_FEED_ATOM = None
@ -167,9 +167,9 @@ I'm getting a warning about feeds generated without SITEURL being set properly
============================================================================== ==============================================================================
`RSS and Atom feeds require all URL links to be absolute `RSS and Atom feeds require all URL links to be absolute
<http://validator.w3.org/feed/docs/rss2.html#comments>`_. <http://validator.w3.org/feed/docs/rss2.html#comments>`_. In order to properly
In order to properly generate links in Pelican you will need to set ``SITEURL`` generate links in Pelican you will need to set ``SITEURL`` to the full path of
to the full path of your site. your site.
Feeds are still generated when this warning is displayed, but links within may Feeds are still generated when this warning is displayed, but links within may
be malformed and thus the feed may not validate. be malformed and thus the feed may not validate.
@ -185,26 +185,26 @@ setting names). Here is an exact list of the renamed settings::
TAG_FEED -> TAG_FEED_ATOM TAG_FEED -> TAG_FEED_ATOM
CATEGORY_FEED -> CATEGORY_FEED_ATOM CATEGORY_FEED -> CATEGORY_FEED_ATOM
Starting in 3.1, the new feed ``FEED_ALL_ATOM`` has been introduced: this Starting in 3.1, the new feed ``FEED_ALL_ATOM`` has been introduced: this feed
feed will aggregate all posts regardless of their language. This setting will aggregate all posts regardless of their language. This setting generates
generates ``'feeds/all.atom.xml'`` by default and ``FEED_ATOM`` now defaults to ``'feeds/all.atom.xml'`` by default and ``FEED_ATOM`` now defaults to ``None``.
``None``. The following feed setting has also been renamed:: The following feed setting has also been renamed::
TRANSLATION_FEED -> TRANSLATION_FEED_ATOM TRANSLATION_FEED -> TRANSLATION_FEED_ATOM
Older themes that referenced the old setting names may not link properly. Older themes that referenced the old setting names may not link properly. In
In order to rectify this, please update your theme for compatibility by changing order to rectify this, please update your theme for compatibility by changing
the relevant values in your template files. For an example of complete feed the relevant values in your template files. For an example of complete feed
headers and usage please check out the ``simple`` theme. headers and usage please check out the ``simple`` theme.
Is Pelican only suitable for blogs? Is Pelican only suitable for blogs?
=================================== ===================================
No. Pelican can be easily configured to create and maintain any type of static site. No. Pelican can be easily configured to create and maintain any type of static
This may require a little customization of your theme and Pelican configuration. site. This may require a little customization of your theme and Pelican
For example, if you are building a launch site for your product and do not need configuration. For example, if you are building a launch site for your product
tags on your site, you could remove the relevant HTML code from your theme. and do not need tags on your site, you could remove the relevant HTML code from
You can also disable generation of tag-related pages via:: your theme. You can also disable generation of tag-related pages via::
TAGS_SAVE_AS = '' TAGS_SAVE_AS = ''
TAG_SAVE_AS = '' TAG_SAVE_AS = ''
@ -212,52 +212,49 @@ You can also disable generation of tag-related pages via::
Why does Pelican always write all HTML files even with content caching enabled? Why does Pelican always write all HTML files even with content caching enabled?
=============================================================================== ===============================================================================
In order to reliably determine whether the HTML output is different In order to reliably determine whether the HTML output is different before
before writing it, a large part of the generation environment writing it, a large part of the generation environment including the template
including the template contexts, imported plugins, etc. would have to contexts, imported plugins, etc. would have to be saved and compared, at least
be saved and compared, at least in the form of a hash (which would in the form of a hash (which would require special handling of unhashable
require special handling of unhashable types), because of all the types), because of all the possible combinations of plugins, pagination, etc.
possible combinations of plugins, pagination, etc. which may change in which may change in many different ways. This would require a lot more
many different ways. This would require a lot more processing time processing time and memory and storage space. Simply writing the files each
and memory and storage space. Simply writing the files each time is a time is a lot faster and a lot more reliable.
lot faster and a lot more reliable.
However, this means that the modification time of the files changes However, this means that the modification time of the files changes every time,
every time, so a ``rsync`` based upload will transfer them even if so a ``rsync`` based upload will transfer them even if their content hasn't
their content hasn't changed. A simple solution is to make ``rsync`` changed. A simple solution is to make ``rsync`` use the ``--checksum`` option,
use the ``--checksum`` option, which will make it compare the file which will make it compare the file checksums in a much faster way than Pelican
checksums in a much faster way than Pelican would. would.
When only several specific output files are of interest (e.g. when When only several specific output files are of interest (e.g. when working on
working on some specific page or the theme templates), the some specific page or the theme templates), the `WRITE_SELECTED` option may
`WRITE_SELECTED` option may help, see help, see :ref:`writing_only_selected_content`.
:ref:`writing_only_selected_content`.
How to process only a subset of all articles? How to process only a subset of all articles?
============================================= =============================================
It is often useful to process only e.g. 10 articles for debugging It is often useful to process only e.g. 10 articles for debugging purposes.
purposes. This can be achieved by explicitly specifying only the This can be achieved by explicitly specifying only the filenames of those
filenames of those articles in ``ARTICLE_PATHS``. A list of such articles in ``ARTICLE_PATHS``. A list of such filenames could be found using a
filenames could be found using a command similar to ``cd content; command similar to ``cd content; find -name '*.md' | head -n 10``.
find -name '*.md' | head -n 10``.
My tag-cloud is missing/broken since I upgraded Pelican My tag-cloud is missing/broken since I upgraded Pelican
======================================================= =======================================================
In an ongoing effort to steamline Pelican, `tag_cloud` generation has been In an ongoing effort to steamline Pelican, `tag_cloud` generation has been
moved out of the pelican core and into a separate `plugin moved out of the pelican core and into a separate `plugin
<https://github.com/getpelican/pelican-plugins/tree/master/tag_cloud>`_. <https://github.com/getpelican/pelican-plugins/tree/master/tag_cloud>`_. See
See the :ref:`plugins` documentation further information about the the :ref:`plugins` documentation further information about the Pelican plugin
Pelican plugin system. system.
Since I upgraded Pelican my pages are no longer rendered Since I upgraded Pelican my pages are no longer rendered
======================================================== ========================================================
Pages were available to themes as lowercase ``pages`` and uppercase Pages were available to themes as lowercase ``pages`` and uppercase ``PAGES``.
``PAGES``. To bring this inline with the :ref:`templates-variables` section, To bring this inline with the :ref:`templates-variables` section, ``PAGES`` has
``PAGES`` has been removed. This is quickly resolved by updating your theme been removed. This is quickly resolved by updating your theme to iterate over
to iterate over ``pages`` instead of ``PAGES``. Just replace:: ``pages`` instead of ``PAGES``. Just replace::
{% for pg in PAGES %} {% for pg in PAGES %}
@ -271,8 +268,8 @@ How can I stop Pelican from trying to parse my static files as content?
Pelican's article and page generators run before it's static generator. That Pelican's article and page generators run before it's static generator. That
means if you use a setup similar to the default configuration, where a static means if you use a setup similar to the default configuration, where a static
source directory is defined inside a ``*_PATHS`` setting, all files that have a source directory is defined inside a ``*_PATHS`` setting, all files that have a
valid content file ending (``.html``, ``.rst``, ``.md``, ...) will be treated as valid content file ending (``.html``, ``.rst``, ``.md``, ...) will be treated
articles or pages before they get treated as static files. as articles or pages before they get treated as static files.
To circumvent this issue either use the appropriate ``*_EXCLUDES`` setting or To circumvent this issue either use the appropriate ``*_EXCLUDES`` setting or
disable the offending reader via ``READERS`` if you don't need it. disable the offending reader via ``READERS`` if you don't need it.

View file

@ -26,8 +26,9 @@ Dependencies
``pelican-import`` has some dependencies not required by the rest of Pelican: ``pelican-import`` has some dependencies not required by the rest of Pelican:
- *BeautifulSoup4* and *lxml*, for WordPress and Dotclear import. Can be installed like - *BeautifulSoup4* and *lxml*, for WordPress and Dotclear import. Can be
any other Python package (``pip install BeautifulSoup4 lxml``). installed like any other Python package (``pip install BeautifulSoup4
lxml``).
- *Feedparser*, for feed import (``pip install feedparser``). - *Feedparser*, for feed import (``pip install feedparser``).
- *Pandoc*, see the `Pandoc site`_ for installation instructions on your - *Pandoc*, see the `Pandoc site`_ for installation instructions on your
operating system. operating system.

View file

@ -6,14 +6,14 @@ Pelican |release|
.. warning:: .. warning::
This documentation is for the version of Pelican currently under development. This documentation is for the version of Pelican currently under
Were you looking for version |last_stable| documentation? development. Were you looking for version |last_stable| documentation?
Pelican is a static site generator, written in Python_. Highlights include: Pelican is a static site generator, written in Python_. Highlights include:
* Write your content directly with your editor of choice * Write your content directly with your editor of choice in reStructuredText_
in reStructuredText_ or Markdown_ formats or Markdown_ formats
* Includes a simple CLI tool to (re)generate your site * Includes a simple CLI tool to (re)generate your site
* Easy to interface with distributed version control systems and web hooks * Easy to interface with distributed version control systems and web hooks
* Completely static output is easy to host anywhere * Completely static output is easy to host anywhere

View file

@ -12,8 +12,8 @@ You can install Pelican via several different methods. The simplest is via
(Keep in mind that operating systems will often require you to prefix the above (Keep in mind that operating systems will often require you to prefix the above
command with ``sudo`` in order to install Pelican system-wide.) command with ``sudo`` in order to install Pelican system-wide.)
While the above is the simplest method, the recommended approach is to create While the above is the simplest method, the recommended approach is to create a
a virtual environment for Pelican via virtualenv_ before installing Pelican. virtual environment for Pelican via virtualenv_ before installing Pelican.
Assuming you have virtualenv_ installed, you can then open a new terminal Assuming you have virtualenv_ installed, you can then open a new terminal
session and create a new virtual environment for Pelican:: session and create a new virtual environment for Pelican::
@ -22,9 +22,8 @@ session and create a new virtual environment for Pelican::
source bin/activate source bin/activate
Once the virtual environment has been created and activated, Pelican can be Once the virtual environment has been created and activated, Pelican can be
installed via ``pip install pelican`` as noted above. Alternatively, if installed via ``pip install pelican`` as noted above. Alternatively, if you
you have the project source, you can install Pelican using the distutils have the project source, you can install Pelican using the distutils method::
method::
cd path-to-Pelican-source cd path-to-Pelican-source
python setup.py install python setup.py install
@ -96,8 +95,9 @@ your site::
pelican-quickstart pelican-quickstart
Once you finish answering all the questions, your project will consist of the Once you finish answering all the questions, your project will consist of the
following hierarchy (except for *pages* — shown in parentheses below — which you following hierarchy (except for *pages* — shown in parentheses below — which
can optionally add yourself if you plan to create non-chronological content):: you can optionally add yourself if you plan to create non-chronological
content)::
yourproject/ yourproject/
├── content ├── content

View file

@ -1,8 +1,8 @@
Pelican internals Pelican internals
################# #################
This section describe how Pelican works internally. As you'll see, it's This section describe how Pelican works internally. As you'll see, it's quite
quite simple, but a bit of documentation doesn't hurt. :) simple, but a bit of documentation doesn't hurt. :)
You can also find in the :doc:`report` section an excerpt of a report the You can also find in the :doc:`report` section an excerpt of a report the
original author wrote with some software design information. original author wrote with some software design information.
@ -13,9 +13,8 @@ Overall structure
================= =================
What Pelican does is take a list of files and process them into some sort of What Pelican does is take a list of files and process them into some sort of
output. Usually, the input files are reStructuredText and Markdown output. Usually, the input files are reStructuredText and Markdown files, and
files, and the output is a blog, but both input and output can be anything you the output is a blog, but both input and output can be anything you want.
want.
The logic is separated into different classes and concepts: The logic is separated into different classes and concepts:
@ -27,9 +26,10 @@ The logic is separated into different classes and concepts:
reStructuredText for now, but the system is extensible). Given a file, they reStructuredText for now, but the system is extensible). Given a file, they
return metadata (author, tags, category, etc.) and content (HTML-formatted). return metadata (author, tags, category, etc.) and content (HTML-formatted).
* **Generators** generate the different outputs. For instance, Pelican comes with * **Generators** generate the different outputs. For instance, Pelican comes
``ArticlesGenerator`` and ``PageGenerator``. Given a configuration, they can do with ``ArticlesGenerator`` and ``PageGenerator``. Given a configuration, they
whatever they want. Most of the time, it's generating files from inputs. can do whatever they want. Most of the time, it's generating files from
inputs.
* Pelican also uses templates, so it's easy to write your own theme. The * Pelican also uses templates, so it's easy to write your own theme. The
syntax is `Jinja2 <http://jinja.pocoo.org/>`_ and is very easy to learn, so syntax is `Jinja2 <http://jinja.pocoo.org/>`_ and is very easy to learn, so
@ -38,9 +38,9 @@ The logic is separated into different classes and concepts:
How to implement a new reader? How to implement a new reader?
============================== ==============================
Is there an awesome markup language you want to add to Pelican? Is there an awesome markup language you want to add to Pelican? Well, the only
Well, the only thing you have to do is to create a class with a ``read`` thing you have to do is to create a class with a ``read`` method that returns
method that returns HTML content and some metadata. HTML content and some metadata.
Take a look at the Markdown reader:: Take a look at the Markdown reader::
@ -65,17 +65,17 @@ Take a look at the Markdown reader::
Simple, isn't it? Simple, isn't it?
If your new reader requires additional Python dependencies, then you should wrap If your new reader requires additional Python dependencies, then you should
their ``import`` statements in a ``try...except`` block. Then inside the reader's wrap their ``import`` statements in a ``try...except`` block. Then inside the
class, set the ``enabled`` class attribute to mark import success or failure. reader's class, set the ``enabled`` class attribute to mark import success or
This makes it possible for users to continue using their favourite markup method failure. This makes it possible for users to continue using their favourite
without needing to install modules for formats they don't use. markup method without needing to install modules for formats they don't use.
How to implement a new generator? How to implement a new generator?
================================= =================================
Generators have two important methods. You're not forced to create Generators have two important methods. You're not forced to create both; only
both; only the existing ones will be called. the existing ones will be called.
* ``generate_context``, that is called first, for all the generators. * ``generate_context``, that is called first, for all the generators.
Do whatever you have to do, and update the global context if needed. This Do whatever you have to do, and update the global context if needed. This
@ -89,5 +89,5 @@ both; only the existing ones will be called.
generating the output. :) It's here that you may want to look at the context generating the output. :) It's here that you may want to look at the context
and call the methods of the ``writer`` object that is passed as the first and call the methods of the ``writer`` object that is passed as the first
argument of this function. In the ``PageGenerator`` example, this method will argument of this function. In the ``PageGenerator`` example, this method will
look at all the pages recorded in the global context and output a file on look at all the pages recorded in the global context and output a file on the
the disk (using the writer method ``write_file``) for each page encountered. disk (using the writer method ``write_file``) for each page encountered.

View file

@ -44,7 +44,8 @@ Examples
Listing the installed themes Listing the installed themes
"""""""""""""""""""""""""""" """"""""""""""""""""""""""""
With ``pelican-themes``, you can see the available themes by using the ``-l`` or ``--list`` option: With ``pelican-themes``, you can see the available themes by using the ``-l``
or ``--list`` option:
.. code-block:: console .. code-block:: console
@ -57,11 +58,15 @@ With ``pelican-themes``, you can see the available themes by using the ``-l`` or
two-column@ two-column@
simple simple
In this example, we can see there are three themes available: ``notmyidea``, ``simple``, and ``two-column``. In this example, we can see there are three themes available: ``notmyidea``,
``simple``, and ``two-column``.
``two-column`` is prefixed with an ``@`` because this theme is not copied to the Pelican theme path, but is instead just linked to it (see `Creating symbolic links`_ for details about creating symbolic links). ``two-column`` is prefixed with an ``@`` because this theme is not copied to
the Pelican theme path, but is instead just linked to it (see `Creating
symbolic links`_ for details about creating symbolic links).
Note that you can combine the ``--list`` option with the ``-v`` or ``--verbose`` option to get more verbose output, like this: Note that you can combine the ``--list`` option with the ``-v`` or
``--verbose`` option to get more verbose output, like this:
.. code-block:: console .. code-block:: console
@ -75,7 +80,8 @@ Installing themes
""""""""""""""""" """""""""""""""""
You can install one or more themes using the ``-i`` or ``--install`` option. You can install one or more themes using the ``-i`` or ``--install`` option.
This option takes as argument the path(s) of the theme(s) you want to install, and can be combined with the verbose option: This option takes as argument the path(s) of the theme(s) you want to install,
and can be combined with the verbose option:
.. code-block:: console .. code-block:: console
@ -95,8 +101,9 @@ This option takes as argument the path(s) of the theme(s) you want to install, a
Removing themes Removing themes
""""""""""""""" """""""""""""""
The ``pelican-themes`` command can also remove themes from the Pelican themes path. The ``pelican-themes`` command can also remove themes from the Pelican themes
The ``-r`` or ``--remove`` option takes as argument the name(s) of the theme(s) you want to remove, and can be combined with the ``--verbose`` option. path. The ``-r`` or ``--remove`` option takes as argument the name(s) of the
theme(s) you want to remove, and can be combined with the ``--verbose`` option.
.. code-block:: console .. code-block:: console
@ -113,15 +120,19 @@ The ``-r`` or ``--remove`` option takes as argument the name(s) of the theme(s)
Creating symbolic links Creating symbolic links
""""""""""""""""""""""" """""""""""""""""""""""
``pelican-themes`` can also install themes by creating symbolic links instead of copying entire themes into the Pelican themes path. ``pelican-themes`` can also install themes by creating symbolic links instead
of copying entire themes into the Pelican themes path.
To symbolically link a theme, you can use the ``-s`` or ``--symlink``, which works exactly as the ``--install`` option: To symbolically link a theme, you can use the ``-s`` or ``--symlink``, which
works exactly as the ``--install`` option:
.. code-block:: console .. code-block:: console
# pelican-themes --symlink ~/Dev/Python/pelican-themes/two-column # pelican-themes --symlink ~/Dev/Python/pelican-themes/two-column
In this example, the ``two-column`` theme is now symbolically linked to the Pelican themes path, so we can use it, but we can also modify it without having to reinstall it after each modification. In this example, the ``two-column`` theme is now symbolically linked to the
Pelican themes path, so we can use it, but we can also modify it without having
to reinstall it after each modification.
This is useful for theme development: This is useful for theme development:
@ -142,7 +153,9 @@ This is useful for theme development:
Doing several things at once Doing several things at once
"""""""""""""""""""""""""""" """"""""""""""""""""""""""""
The ``--install``, ``--remove`` and ``--symlink`` option are not mutually exclusive, so you can combine them in the same command line to do more than one operation at time, like this: The ``--install``, ``--remove`` and ``--symlink`` option are not mutually
exclusive, so you can combine them in the same command line to do more than one
operation at time, like this:
.. code-block:: console .. code-block:: console
@ -152,4 +165,5 @@ The ``--install``, ``--remove`` and ``--symlink`` option are not mutually exclus
--symlink ~/Dev/Python/pelican-themes/two-column \ --symlink ~/Dev/Python/pelican-themes/two-column \
--verbose --verbose
In this example, the theme ``notmyidea-cms`` is replaced by the theme ``notmyidea-cms-fr`` In this example, the theme ``notmyidea-cms`` is replaced by the theme
``notmyidea-cms-fr``

View file

@ -22,11 +22,10 @@ Alternatively, another method is to import them and add them to the list::
.. note:: .. note::
When experimenting with different plugins (especially the ones that When experimenting with different plugins (especially the ones that deal
deal with metadata and content) caching may interfere and the with metadata and content) caching may interfere and the changes may not be
changes may not be visible. In such cases disable caching with visible. In such cases disable caching with ``LOAD_CONTENT_CACHE = False``
``LOAD_CONTENT_CACHE = False`` or use the ``--ignore-cache`` or use the ``--ignore-cache`` command-line switch.
command-line switch.
If your plugins are not in an importable path, you can specify a list of paths If your plugins are not in an importable path, you can specify a list of paths
via the ``PLUGIN_PATHS`` setting. As shown in the following example, paths in via the ``PLUGIN_PATHS`` setting. As shown in the following example, paths in
@ -126,17 +125,17 @@ feed_written path, context, feed invoked each
.. warning:: .. warning::
Avoid ``content_object_init`` signal if you intend to read ``summary`` Avoid ``content_object_init`` signal if you intend to read ``summary`` or
or ``content`` properties of the content object. That combination can ``content`` properties of the content object. That combination can result in
result in unresolved links when :ref:`ref-linking-to-internal-content` unresolved links when :ref:`ref-linking-to-internal-content` (see
(see `pelican-plugins bug #314`_). Use ``_summary`` and ``_content`` `pelican-plugins bug #314`_). Use ``_summary`` and ``_content`` properties
properties instead, or, alternatively, run your plugin at a later instead, or, alternatively, run your plugin at a later stage (e.g.
stage (e.g. ``all_generators_finalized``). ``all_generators_finalized``).
.. note:: .. note::
After Pelican 3.2, signal names were standardized. Older plugins After Pelican 3.2, signal names were standardized. Older plugins may need
may need to be updated to use the new names: to be updated to use the new names:
========================== =========================== ========================== ===========================
Old name New name Old name New name
@ -162,9 +161,9 @@ How to create a new reader
-------------------------- --------------------------
One thing you might want is to add support for your very own input format. One thing you might want is to add support for your very own input format.
While it might make sense to add this feature in Pelican core, we While it might make sense to add this feature in Pelican core, we wisely chose
wisely chose to avoid this situation and instead have the different readers to avoid this situation and instead have the different readers defined via
defined via plugins. plugins.
The rationale behind this choice is mainly that plugins are really easy to The rationale behind this choice is mainly that plugins are really easy to
write and don't slow down Pelican itself when they're not active. write and don't slow down Pelican itself when they're not active.

View file

@ -26,13 +26,13 @@ argument, like so::
Note that you must specify the path to the generated *output* file — not the Note that you must specify the path to the generated *output* file — not the
source content. To determine the output file name and location, use the source content. To determine the output file name and location, use the
``--debug`` flag. If desired, ``--write-selected`` ``--debug`` flag. If desired, ``--write-selected`` can take a comma-separated
can take a comma-separated list of paths or can be configured as a setting. list of paths or can be configured as a setting. (See:
(See: :ref:`writing_only_selected_content`) :ref:`writing_only_selected_content`)
You can also tell Pelican to watch for your modifications, instead of You can also tell Pelican to watch for your modifications, instead of manually
manually re-running it every time you want to see your changes. To enable this, re-running it every time you want to see your changes. To enable this, run the
run the ``pelican`` command with the ``-r`` or ``--autoreload`` option. ``pelican`` command with the ``-r`` or ``--autoreload`` option.
Pelican has other command-line switches available. Have a look at the help to Pelican has other command-line switches available. Have a look at the help to
see all the options you can use:: see all the options you can use::
@ -75,17 +75,17 @@ feeds, etc.) that you may have defined::
pelican content -s publishconf.py pelican content -s publishconf.py
To base your publish configuration on top of your ``pelicanconf.py``, you To base your publish configuration on top of your ``pelicanconf.py``, you can
can import your ``pelicanconf`` settings by including the following line in import your ``pelicanconf`` settings by including the following line in your
your ``publishconf.py``:: ``publishconf.py``::
from pelicanconf import * from pelicanconf import *
If you have generated a ``publishconf.py`` using ``pelican-quickstart``, If you have generated a ``publishconf.py`` using ``pelican-quickstart``, this
this line is included by default. line is included by default.
The steps for deploying your site will depend on where it will be hosted. The steps for deploying your site will depend on where it will be hosted. If
If you have SSH access to a server running Nginx or Apache, you might use the you have SSH access to a server running Nginx or Apache, you might use the
``rsync`` tool to transmit your site files:: ``rsync`` tool to transmit your site files::
rsync -avc --delete output/ host.example.com:/var/www/your-site/ rsync -avc --delete output/ host.example.com:/var/www/your-site/
@ -98,17 +98,17 @@ Automation
========== ==========
While the ``pelican`` command is the canonical way to generate your site, While the ``pelican`` command is the canonical way to generate your site,
automation tools can be used to streamline the generation and publication automation tools can be used to streamline the generation and publication flow.
flow. One of the questions asked during the ``pelican-quickstart`` process One of the questions asked during the ``pelican-quickstart`` process pertains
pertains to whether you want to automate site generation and publication. to whether you want to automate site generation and publication. If you
If you answered "yes" to that question, a ``tasks.py`` and answered "yes" to that question, a ``tasks.py`` and ``Makefile`` will be
``Makefile`` will be generated in the root of your project. These files, generated in the root of your project. These files, pre-populated with certain
pre-populated with certain information gleaned from other answers provided information gleaned from other answers provided during the
during the ``pelican-quickstart`` process, are meant as a starting point and ``pelican-quickstart`` process, are meant as a starting point and should be
should be customized to fit your particular needs and usage patterns. If you customized to fit your particular needs and usage patterns. If you find one or
find one or both of these automation tools to be of limited utility, these both of these automation tools to be of limited utility, these files can
files can deleted at any time and will not affect usage of the canonical deleted at any time and will not affect usage of the canonical ``pelican``
``pelican`` command. command.
Following are automation tools that "wrap" the ``pelican`` command and can Following are automation tools that "wrap" the ``pelican`` command and can
simplify the process of generating, previewing, and uploading your site. simplify the process of generating, previewing, and uploading your site.
@ -123,9 +123,9 @@ separately. Use the following command to install Invoke, prefixing with
pip install invoke pip install invoke
Take a moment to open the ``tasks.py`` file that was generated in your Take a moment to open the ``tasks.py`` file that was generated in your project
project root. You will see a number of commands, any one of which can be root. You will see a number of commands, any one of which can be renamed,
renamed, removed, and/or customized to your liking. Using the out-of-the-box removed, and/or customized to your liking. Using the out-of-the-box
configuration, you can generate your site via:: configuration, you can generate your site via::
invoke build invoke build
@ -155,12 +155,12 @@ needs and preferences.
Make Make
---- ----
A ``Makefile`` is also automatically created for you when you say "yes" to A ``Makefile`` is also automatically created for you when you say "yes" to the
the relevant question during the ``pelican-quickstart`` process. The advantage relevant question during the ``pelican-quickstart`` process. The advantage of
of this method is that the ``make`` command is built into most POSIX systems this method is that the ``make`` command is built into most POSIX systems and
and thus doesn't require installing anything else in order to use it. The thus doesn't require installing anything else in order to use it. The downside
downside is that non-POSIX systems (e.g., Windows) do not include ``make``, is that non-POSIX systems (e.g., Windows) do not include ``make``, and
and installing it on those systems can be a non-trivial task. installing it on those systems can be a non-trivial task.
If you want to use ``make`` to generate your site using the settings in If you want to use ``make`` to generate your site using the settings in
``pelicanconf.py``, run:: ``pelicanconf.py``, run::

View file

@ -54,9 +54,9 @@ From your site directory, run the ``pelican`` command to generate your site::
pelican content pelican content
Your site has now been generated inside the ``output`` directory. (You may see a Your site has now been generated inside the ``output`` directory. (You may see
warning related to feeds, but that is normal when developing locally and can be a warning related to feeds, but that is normal when developing locally and can
ignored for now.) be ignored for now.)
Preview your site Preview your site
----------------- -----------------
@ -68,8 +68,9 @@ following command to launch Pelican's web server::
Preview your site by navigating to http://localhost:8000/ in your browser. Preview your site by navigating to http://localhost:8000/ in your browser.
Continue reading the other documentation sections for more detail, and check out Continue reading the other documentation sections for more detail, and check
the Pelican wiki's Tutorials_ page for links to community-published tutorials. out the Pelican wiki's Tutorials_ page for links to community-published
tutorials.
.. _Tutorials: https://github.com/getpelican/pelican/wiki/Tutorials .. _Tutorials: https://github.com/getpelican/pelican/wiki/Tutorials

View file

@ -7,29 +7,27 @@ Some history about Pelican
right after writing Pelican, in December 2010. The information may not be right after writing Pelican, in December 2010. The information may not be
up-to-date. up-to-date.
Pelican is a simple static blog generator. It parses markup files Pelican is a simple static blog generator. It parses markup files (Markdown or
(Markdown or reStructuredText for now) and generates an HTML folder reStructuredText for now) and generates an HTML folder with all the files in
with all the files in it. it. I've chosen to use Python to implement Pelican because it seemed to be
I've chosen to use Python to implement Pelican because it seemed to simple and to fit to my needs. I did not wanted to define a class for each
be simple and to fit to my needs. I did not wanted to define a class for thing, but still wanted to keep my things loosely coupled. It turns out that it
each thing, but still wanted to keep my things loosely coupled. was exactly what I wanted. From time to time, thanks to the feedback of some
It turns out that it was exactly what I wanted. From time to time, users, it took me a very few time to provide fixes on it. So far, I've
thanks to the feedback of some users, it took me a very few time to re-factored the Pelican code by two
provide fixes on it. So far, I've re-factored the Pelican code by two
times; each time took less than 30 minutes. times; each time took less than 30 minutes.
Use case Use case
======== ========
I was previously using WordPress, a solution you can host on a web I was previously using WordPress, a solution you can host on a web server to
server to manage your blog. Most of the time, I prefer using markup manage your blog. Most of the time, I prefer using markup languages such as
languages such as Markdown or reStructuredText to type my articles. Markdown or reStructuredText to type my articles. To do so, I use vim. I think
To do so, I use vim. I think it is important to let the people choose the it is important to let the people choose the tool they want to write the
tool they want to write the articles. In my opinion, a blog manager articles. In my opinion, a blog manager should just allow you to take any kind
should just allow you to take any kind of input and transform it to a of input and transform it to a weblog. That's what Pelican does. You can write
weblog. That's what Pelican does. your articles using the tool you want, and the markup language you want, and
You can write your articles using the tool you want, and the markup then generate a static HTML weblog.
language you want, and then generate a static HTML weblog.
.. image:: _static/overall.png .. image:: _static/overall.png
@ -40,39 +38,36 @@ Design process
============== ==============
Pelican came from a need I have. I started by creating a single file Pelican came from a need I have. I started by creating a single file
application, and I have make it grow to support what it does by now. application, and I have make it grow to support what it does by now. To start,
To start, I wrote a piece of documentation about what I wanted to do. I wrote a piece of documentation about what I wanted to do. Then, I created the
Then, I created the content I wanted to parse (the reStructuredText files) content I wanted to parse (the reStructuredText files) and started
and started experimenting with the code. Pelican was 200 lines long and experimenting with the code. Pelican was 200 lines long and contained almost
contained almost ten functions and one class when it was first usable. ten functions and one class when it was first usable.
I have been facing different problems all over the time and wanted to I have been facing different problems all over the time and wanted to add
add features to Pelican while using it. The first change I have done was features to Pelican while using it. The first change I have done was to add the
to add the support of a settings file. It is possible to pass the options to support of a settings file. It is possible to pass the options to the command
the command line, but can be tedious if there is a lot of them. line, but can be tedious if there is a lot of them. In the same way, I have
In the same way, I have added the support of different things over added the support of different things over time: Atom feeds, multiple themes,
time: Atom feeds, multiple themes, multiple markup support, etc. multiple markup support, etc. At some point, it appears that the "only one
At some point, it appears that the "only one file" mantra was not good file" mantra was not good enough for Pelican, so I decided to rework a bit all
enough for Pelican, so I decided to rework a bit all that, and split this in that, and split this in multiple different files.
multiple different files.
Ive separated the logic in different classes and concepts: Ive separated the logic in different classes and concepts:
* *writers* are responsible of all the writing process of the files. * *writers* are responsible of all the writing process of the files.
They are responsible of writing .html files, RSS feeds and so on. They are responsible of writing .html files, RSS feeds and so on. Since those
Since those operations are commonly used, the object is created operations are commonly used, the object is created once, and then passed to
once, and then passed to the generators. the generators.
* *readers* are used to read from various formats (Markdown and * *readers* are used to read from various formats (Markdown and
reStructuredText for now, but the system is extensible). Given a reStructuredText for now, but the system is extensible). Given a file, they
file, they return metadata (author, tags, category, etc) and return metadata (author, tags, category, etc) and content (HTML formatted).
content (HTML formatted).
* *generators* generate the different outputs. For instance, Pelican * *generators* generate the different outputs. For instance, Pelican
comes with an ArticlesGenerator and PagesGenerator, into comes with an ArticlesGenerator and PagesGenerator, into others. Given a
others. Given a configuration, they can do whatever you want configuration, they can do whatever you want them to do. Most of the time
them to do. Most of the time it's generating files from inputs it's generating files from inputs (user inputs and files).
(user inputs and files).
I also deal with contents objects. They can be ``Articles``, ``Pages``, I also deal with contents objects. They can be ``Articles``, ``Pages``,
``Quotes``, or whatever you want. They are defined in the ``contents.py`` ``Quotes``, or whatever you want. They are defined in the ``contents.py``
@ -90,32 +85,30 @@ whole picture. I do use duck typing and not interfaces.
Internally, the following process is followed: Internally, the following process is followed:
* First of all, the command line is parsed, and some content from * First of all, the command line is parsed, and some content from the user is
the user is used to initialize the different generator objects. used to initialize the different generator objects.
* A ``context`` is created. It contains the settings from the command * A ``context`` is created. It contains the settings from the command line and
line and a settings file if provided. a settings file if provided.
* The ``generate_context`` method of each generator is called, updating * The ``generate_context`` method of each generator is called, updating
the context. the context.
* The writer is created and given to the ``generate_output`` method of each
generator.
* The writer is created and given to the ``generate_output`` method of I make two calls because it is important that when the output is generated by
each generator. the generators, the context will not change. In other words, the first method
``generate_context`` should modify the context, whereas the second
I make two calls because it is important that when the output is ``generate_output`` method should not.
generated by the generators, the context will not change. In other
words, the first method ``generate_context`` should modify the context,
whereas the second ``generate_output`` method should not.
Then, it is up to the generators to do what the want, in the Then, it is up to the generators to do what the want, in the
``generate_context`` and ``generate_content`` method. ``generate_context`` and ``generate_content`` method. Taking the
Taking the ``ArticlesGenerator`` class will help to understand some others ``ArticlesGenerator`` class will help to understand some others concepts. Here
concepts. Here is what happens when calling the ``generate_context`` is what happens when calling the ``generate_context`` method:
method:
* Read the folder “path”, looking for restructured text files, load * Read the folder “path”, looking for restructured text files, load each of
each of them, and construct a content object (``Article``) with it. To do so, them, and construct a content object (``Article``) with it. To do so, use
use ``Reader`` objects. ``Reader`` objects.
* Update the ``context`` with all those articles. * Update the ``context`` with all those articles.
Then, the ``generate_content`` method uses the ``context`` and the ``writer`` to Then, the ``generate_content`` method uses the ``context`` and the ``writer``
generate the wanted output. to generate the wanted output.

View file

@ -1,8 +1,8 @@
Settings Settings
######## ########
Pelican is configurable thanks to a settings file you can pass to Pelican is configurable thanks to a settings file you can pass to the command
the command line:: line::
pelican content -s path/to/your/pelicanconf.py pelican content -s path/to/your/pelicanconf.py
@ -11,10 +11,10 @@ be named ``pelicanconf.py`` by default.
.. note:: .. note::
When experimenting with different settings (especially the metadata When experimenting with different settings (especially the metadata ones)
ones) caching may interfere and the changes may not be visible. In caching may interfere and the changes may not be visible. In such cases
such cases disable caching with ``LOAD_CONTENT_CACHE = False`` or disable caching with ``LOAD_CONTENT_CACHE = False`` or use the
use the ``--ignore-cache`` command-line switch. ``--ignore-cache`` command-line switch.
Settings are configured in the form of a Python module (a file). There is an Settings are configured in the form of a Python module (a file). There is an
`example settings file `example settings file
@ -35,8 +35,8 @@ quotation marks.
Unless otherwise specified, settings that refer to paths can be either absolute Unless otherwise specified, settings that refer to paths can be either absolute
or relative to the configuration file. The settings you define in the or relative to the configuration file. The settings you define in the
configuration file will be passed to the templates, which allows you to use your configuration file will be passed to the templates, which allows you to use
settings to add site-wide content. your settings to add site-wide content.
Here is a list of settings for Pelican: Here is a list of settings for Pelican:
@ -89,8 +89,8 @@ Basic settings
.. data:: JINJA_ENVIRONMENT = {'trim_blocks': True, 'lstrip_blocks': True} .. data:: JINJA_ENVIRONMENT = {'trim_blocks': True, 'lstrip_blocks': True}
A dictionary of custom Jinja2 environment variables you want to use. This A dictionary of custom Jinja2 environment variables you want to use. This
also includes a list of extensions you may want to include. also includes a list of extensions you may want to include. See `Jinja
See `Jinja Environment documentation`_. Environment documentation`_.
.. data:: JINJA_FILTERS = {} .. data:: JINJA_FILTERS = {}
@ -212,8 +212,8 @@ Basic settings
your SITEURL; if you do not, feeds will not be generated with your SITEURL; if you do not, feeds will not be generated with
properly-formed URLs. If your site is available via HTTPS, this setting properly-formed URLs. If your site is available via HTTPS, this setting
should begin with ``https://`` — otherwise use ``http://``. Then append your should begin with ``https://`` — otherwise use ``http://``. Then append your
domain, with no trailing slash at the end. domain, with no trailing slash at the end. Example: ``SITEURL =
Example: ``SITEURL = 'https://example.com'`` 'https://example.com'``
.. data:: STATIC_PATHS = ['images'] .. data:: STATIC_PATHS = ['images']
@ -239,17 +239,17 @@ Basic settings
.. data:: STATIC_CREATE_LINKS = False .. data:: STATIC_CREATE_LINKS = False
Create links instead of copying files. If the content and output Create links instead of copying files. If the content and output directories
directories are on the same device, then create hard links. Falls are on the same device, then create hard links. Falls back to symbolic
back to symbolic links if the output directory is on a different links if the output directory is on a different filesystem. If symlinks are
filesystem. If symlinks are created, don't forget to add the ``-L`` created, don't forget to add the ``-L`` or ``--copy-links`` option to rsync
or ``--copy-links`` option to rsync when uploading your site. when uploading your site.
.. data:: STATIC_CHECK_IF_MODIFIED = False .. data:: STATIC_CHECK_IF_MODIFIED = False
If set to ``True``, and ``STATIC_CREATE_LINKS`` is ``False``, compare If set to ``True``, and ``STATIC_CREATE_LINKS`` is ``False``, compare mtimes
mtimes of content and output files, and only copy content files that of content and output files, and only copy content files that are newer than
are newer than existing output files. existing output files.
.. data:: TYPOGRIFY = False .. data:: TYPOGRIFY = False
@ -347,11 +347,11 @@ URL settings
============ ============
The first thing to understand is that there are currently two supported methods The first thing to understand is that there are currently two supported methods
for URL formation: *relative* and *absolute*. Relative URLs are useful for URL formation: *relative* and *absolute*. Relative URLs are useful when
when testing locally, and absolute URLs are reliable and most useful when testing locally, and absolute URLs are reliable and most useful when
publishing. One method of supporting both is to have one Pelican configuration publishing. One method of supporting both is to have one Pelican configuration
file for local development and another for publishing. To see an example of this file for local development and another for publishing. To see an example of
type of setup, use the ``pelican-quickstart`` script as described in the this type of setup, use the ``pelican-quickstart`` script as described in the
:doc:`Installation <install>` section, which will produce two separate :doc:`Installation <install>` section, which will produce two separate
configuration files for local development and publishing, respectively. configuration files for local development and publishing, respectively.
@ -365,8 +365,8 @@ and pages anywhere you want.
.. note:: .. note::
If you specify a ``datetime`` directive, it will be substituted using the If you specify a ``datetime`` directive, it will be substituted using the
input files' date metadata attribute. If the date is not specified for a input files' date metadata attribute. If the date is not specified for a
particular file, Pelican will rely on the file's ``mtime`` timestamp. particular file, Pelican will rely on the file's ``mtime`` timestamp. Check
Check the `Python datetime documentation`_ for more information. the `Python datetime documentation`_ for more information.
.. _Python datetime documentation: .. _Python datetime documentation:
http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
@ -387,10 +387,9 @@ Example usage::
PAGE_SAVE_AS = 'pages/{slug}/index.html' PAGE_SAVE_AS = 'pages/{slug}/index.html'
This would save your articles into something like This would save your articles into something like
``/posts/2011/Aug/07/sample-post/index.html``, ``/posts/2011/Aug/07/sample-post/index.html``, save your pages into
save your pages into ``/pages/about/index.html``, and render them available at ``/pages/about/index.html``, and render them available at URLs of
URLs of ``/posts/2011/Aug/07/sample-post/`` and ``/pages/about/``, ``/posts/2011/Aug/07/sample-post/`` and ``/pages/about/``, respectively.
respectively.
.. data:: RELATIVE_URLS = False .. data:: RELATIVE_URLS = False
@ -528,9 +527,10 @@ respectively.
Pelican can optionally create per-year, per-month, and per-day archives of your Pelican can optionally create per-year, per-month, and per-day archives of your
posts. These secondary archives are disabled by default but are automatically posts. These secondary archives are disabled by default but are automatically
enabled if you supply format strings for their respective ``_SAVE_AS`` settings. enabled if you supply format strings for their respective ``_SAVE_AS``
Period archives fit intuitively with the hierarchical model of web URLs and can settings. Period archives fit intuitively with the hierarchical model of web
make it easier for readers to navigate through the posts you've written over time. URLs and can make it easier for readers to navigate through the posts you've
written over time.
Example usage:: Example usage::
@ -543,9 +543,8 @@ posts for the month at ``posts/2011/Aug/index.html``.
.. note:: .. note::
Period archives work best when the final path segment is ``index.html``. Period archives work best when the final path segment is ``index.html``.
This way a reader can remove a portion of your URL and automatically This way a reader can remove a portion of your URL and automatically arrive
arrive at an appropriate archive of posts, without having to specify at an appropriate archive of posts, without having to specify a page name.
a page name.
``DIRECT_TEMPLATES`` work a bit differently than noted above. Only the ``DIRECT_TEMPLATES`` work a bit differently than noted above. Only the
``_SAVE_AS`` settings are available, but it is available for any direct ``_SAVE_AS`` settings are available, but it is available for any direct
@ -585,7 +584,8 @@ template.
URLs for direct template pages are theme-dependent. Some themes use URLs for direct template pages are theme-dependent. Some themes use
corresponding ``*_URL`` setting as string, while others hard-code them: corresponding ``*_URL`` setting as string, while others hard-code them:
``'archives.html'``, ``'authors.html'``, ``'categories.html'``, ``'tags.html'``. ``'archives.html'``, ``'authors.html'``, ``'categories.html'``,
``'tags.html'``.
.. data:: SLUG_REGEX_SUBSTITUTIONS = [ .. data:: SLUG_REGEX_SUBSTITUTIONS = [
(r'[^\w\s-]', ''), # remove non-alphabetical/whitespace/'-' chars (r'[^\w\s-]', ''), # remove non-alphabetical/whitespace/'-' chars
@ -604,11 +604,13 @@ corresponding ``*_URL`` setting as string, while others hard-code them:
.. data:: AUTHOR_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS .. data:: AUTHOR_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
Regex substitutions for author slugs. Defaults to ``SLUG_REGEX_SUBSTITUTIONS``. Regex substitutions for author slugs. Defaults to
``SLUG_REGEX_SUBSTITUTIONS``.
.. data:: CATEGORY_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS .. data:: CATEGORY_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
Regex substitutions for category slugs. Defaults to ``SLUG_REGEX_SUBSTITUTIONS``. Regex substitutions for category slugs. Defaults to
``SLUG_REGEX_SUBSTITUTIONS``.
.. data:: TAG_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS .. data:: TAG_REGEX_SUBSTITUTIONS = SLUG_REGEX_SUBSTITUTIONS
@ -784,13 +786,13 @@ Metadata
unlike some other Pelican file settings. unlike some other Pelican file settings.
Not all metadata needs to be :ref:`embedded in source file itself Not all metadata needs to be :ref:`embedded in source file itself
<internal_metadata>`. For example, blog posts are often named <internal_metadata>`. For example, blog posts are often named following a
following a ``YYYY-MM-DD-SLUG.rst`` pattern, or nested into ``YYYY-MM-DD-SLUG.rst`` pattern, or nested into ``YYYY/MM/DD-SLUG``
``YYYY/MM/DD-SLUG`` directories. To extract metadata from the directories. To extract metadata from the filename or path, set
filename or path, set ``FILENAME_METADATA`` or ``PATH_METADATA`` to ``FILENAME_METADATA`` or ``PATH_METADATA`` to regular expressions that use
regular expressions that use Python's `group name notation`_ ``(?P<name>…)``. Python's `group name notation`_ ``(?P<name>…)``. If you want to attach
If you want to attach additional metadata but don't want to encode additional metadata but don't want to encode it in the path, you can set
it in the path, you can set ``EXTRA_PATH_METADATA``: ``EXTRA_PATH_METADATA``:
.. parsed-literal:: .. parsed-literal::
@ -804,8 +806,8 @@ it in the path, you can set ``EXTRA_PATH_METADATA``:
}, },
} }
This can be a convenient way to shift the installed location of a This can be a convenient way to shift the installed location of a particular
particular file: file:
.. parsed-literal:: .. parsed-literal::
@ -829,8 +831,8 @@ Feed settings
By default, Pelican uses Atom feeds. However, it is also possible to use RSS By default, Pelican uses Atom feeds. However, it is also possible to use RSS
feeds if you prefer. feeds if you prefer.
Pelican generates category feeds as well as feeds for all your articles. It does Pelican generates category feeds as well as feeds for all your articles. It
not generate feeds for tags by default, but it is possible to do so using does not generate feeds for tags by default, but it is possible to do so using
the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings: the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
.. data:: FEED_DOMAIN = None, i.e. base URL is "/" .. data:: FEED_DOMAIN = None, i.e. base URL is "/"
@ -944,7 +946,8 @@ the ``TAG_FEED_ATOM`` and ``TAG_FEED_RSS`` settings:
to ``False``, the full content will be included instead. This setting to ``False``, the full content will be included instead. This setting
doesn't affect Atom feeds, only RSS ones. doesn't affect Atom feeds, only RSS ones.
If you don't want to generate some or any of these feeds, set the above variables to ``None``. If you don't want to generate some or any of these feeds, set the above
variables to ``None``.
.. [2] ``%s`` is replaced by name of the category / author / tag. .. [2] ``%s`` is replaced by name of the category / author / tag.
@ -954,17 +957,18 @@ FeedBurner
If you want to use FeedBurner for your feed, you will likely need to decide If you want to use FeedBurner for your feed, you will likely need to decide
upon a unique identifier. For example, if your site were called "Thyme" and upon a unique identifier. For example, if your site were called "Thyme" and
hosted on the www.example.com domain, you might use "thymefeeds" as your hosted on the www.example.com domain, you might use "thymefeeds" as your unique
unique identifier, which we'll use throughout this section for illustrative identifier, which we'll use throughout this section for illustrative purposes.
purposes. In your Pelican settings, set the ``FEED_ATOM`` attribute to In your Pelican settings, set the ``FEED_ATOM`` attribute to
``thymefeeds/main.xml`` to create an Atom feed with an original address of ``thymefeeds/main.xml`` to create an Atom feed with an original address of
``http://www.example.com/thymefeeds/main.xml``. Set the ``FEED_DOMAIN`` ``http://www.example.com/thymefeeds/main.xml``. Set the ``FEED_DOMAIN``
attribute to ``http://feeds.feedburner.com``, or ``http://feeds.example.com`` if attribute to ``http://feeds.feedburner.com``, or ``http://feeds.example.com``
you are using a CNAME on your own domain (i.e., FeedBurner's "MyBrand" feature). if you are using a CNAME on your own domain (i.e., FeedBurner's "MyBrand"
feature).
There are two fields to configure in the `FeedBurner There are two fields to configure in the `FeedBurner
<http://feedburner.google.com>`_ interface: "Original Feed" and "Feed <http://feedburner.google.com>`_ interface: "Original Feed" and "Feed Address".
Address". In this example, the "Original Feed" would be In this example, the "Original Feed" would be
``http://www.example.com/thymefeeds/main.xml`` and the "Feed Address" suffix ``http://www.example.com/thymefeeds/main.xml`` and the "Feed Address" suffix
would be ``thymefeeds/main.xml``. would be ``thymefeeds/main.xml``.
@ -972,10 +976,10 @@ would be ``thymefeeds/main.xml``.
Pagination Pagination
========== ==========
The default behaviour of Pelican is to list all the article titles along The default behaviour of Pelican is to list all the article titles along with a
with a short description on the index page. While this works well for short description on the index page. While this works well for small-to-medium
small-to-medium sites, sites with a large quantity of articles will probably sites, sites with a large quantity of articles will probably benefit from
benefit from paginating this list. paginating this list.
You can use the following settings to configure the pagination. You can use the following settings to configure the pagination.
@ -1014,9 +1018,9 @@ change this. It takes a sequence of triples, where each triple consists of::
For ``page_url`` and ``page_save_as``, you may use a number of variables. For ``page_url`` and ``page_save_as``, you may use a number of variables.
``{url}`` and ``{save_as}`` correspond respectively to the ``*_URL`` and ``{url}`` and ``{save_as}`` correspond respectively to the ``*_URL`` and
``*_SAVE_AS`` values of the corresponding page type (e.g. ``ARTICLE_SAVE_AS``). ``*_SAVE_AS`` values of the corresponding page type (e.g. ``ARTICLE_SAVE_AS``).
If ``{save_as} == foo/bar.html``, then ``{name} == foo/bar`` and If ``{save_as} == foo/bar.html``, then ``{name} == foo/bar`` and ``{extension}
``{extension} == .html``. ``{base_name}`` equals ``{name}`` except that it == .html``. ``{base_name}`` equals ``{name}`` except that it strips trailing
strips trailing ``/index`` if present. ``{number}`` equals the page number. ``/index`` if present. ``{number}`` equals the page number.
For example, if you want to leave the first page unchanged, but place For example, if you want to leave the first page unchanged, but place
subsequent pages at ``.../page/2/`` etc, you could set ``PAGINATION_PATTERNS`` subsequent pages at ``.../page/2/`` etc, you could set ``PAGINATION_PATTERNS``
@ -1031,8 +1035,8 @@ as follows::
Translations Translations
============ ============
Pelican offers a way to translate articles. See the :doc:`Content <content>` section for Pelican offers a way to translate articles. See the :doc:`Content <content>`
more information. section for more information.
.. data:: DEFAULT_LANG = 'en' .. data:: DEFAULT_LANG = 'en'
@ -1046,9 +1050,9 @@ more information.
.. data:: PAGE_TRANSLATION_ID = 'slug' .. data:: PAGE_TRANSLATION_ID = 'slug'
The metadata attribute(s) used to identify which pages are translations The metadata attribute(s) used to identify which pages are translations of
of one another. May be a string or a collection of strings. Set to ``None`` one another. May be a string or a collection of strings. Set to ``None`` or
or ``False`` to disable the identification of translations. ``False`` to disable the identification of translations.
.. data:: TRANSLATION_FEED_ATOM = 'feeds/all-%s.atom.xml' .. data:: TRANSLATION_FEED_ATOM = 'feeds/all-%s.atom.xml'
@ -1106,8 +1110,9 @@ Ordering content
Themes Themes
====== ======
Creating Pelican themes is addressed in a dedicated section (see :ref:`theming-pelican`). Creating Pelican themes is addressed in a dedicated section (see
However, here are the settings that are related to themes. :ref:`theming-pelican`). However, here are the settings that are related to
themes.
.. data:: THEME .. data:: THEME
@ -1152,11 +1157,13 @@ setting or by passing the ``-t`` option to the ``pelican`` command:
* notmyidea * notmyidea
* simple (a synonym for "plain text" :) * simple (a synonym for "plain text" :)
There are a number of other themes available at https://github.com/getpelican/pelican-themes. There are a number of other themes available at
Pelican comes with :doc:`pelican-themes`, a small script for managing themes. https://github.com/getpelican/pelican-themes. Pelican comes with
:doc:`pelican-themes`, a small script for managing themes.
You can define your own theme, either by starting from scratch or by duplicating You can define your own theme, either by starting from scratch or by
and modifying a pre-existing theme. Here is :doc:`a guide on how to create your theme <themes>`. duplicating and modifying a pre-existing theme. Here is :doc:`a guide on how to
create your theme <themes>`.
Following are example ways to specify your preferred theme:: Following are example ways to specify your preferred theme::
@ -1169,8 +1176,8 @@ Following are example ways to specify your preferred theme::
# Specify a customized theme, via absolute path # Specify a customized theme, via absolute path
THEME = "/home/myuser/projects/mysite/themes/mycustomtheme" THEME = "/home/myuser/projects/mysite/themes/mycustomtheme"
The built-in ``notmyidea`` theme can make good use of the following settings. Feel The built-in ``notmyidea`` theme can make good use of the following settings.
free to use them in your themes as well. Feel free to use them in your themes as well.
.. data:: SITESUBTITLE .. data:: SITESUBTITLE
@ -1256,9 +1263,9 @@ can be quite tricky. In order to filter out redundant log messages, Pelican
comes with the ``LOG_FILTER`` setting. comes with the ``LOG_FILTER`` setting.
``LOG_FILTER`` should be a list of tuples ``(level, msg)``, each of them being ``LOG_FILTER`` should be a list of tuples ``(level, msg)``, each of them being
composed of the logging level (up to ``warning``) and the message to be ignored. composed of the logging level (up to ``warning``) and the message to be
Simply populate the list with the log messages you want to hide, and they will ignored. Simply populate the list with the log messages you want to hide, and
be filtered out. they will be filtered out.
For example:: For example::
@ -1274,6 +1281,7 @@ For example::
LOG_FILTER = [(logging.WARN, 'Empty alt attribute for image %s in %s')] LOG_FILTER = [(logging.WARN, 'Empty alt attribute for image %s in %s')]
.. Warning:: .. Warning::
Silencing messages by templates is a dangerous feature. It is possible to Silencing messages by templates is a dangerous feature. It is possible to
unintentionally filter out multiple message types with the same template unintentionally filter out multiple message types with the same template
(including messages from future Pelican versions). Proceed with caution. (including messages from future Pelican versions). Proceed with caution.
@ -1288,16 +1296,15 @@ For example::
Reading only modified content Reading only modified content
============================= =============================
To speed up the build process, Pelican can optionally read only articles To speed up the build process, Pelican can optionally read only articles and
and pages with modified content. pages with modified content.
When Pelican is about to read some content source file: When Pelican is about to read some content source file:
1. The hash or modification time information for the file from a 1. The hash or modification time information for the file from a
previous build are loaded from a cache file if ``LOAD_CONTENT_CACHE`` previous build are loaded from a cache file if ``LOAD_CONTENT_CACHE`` is
is ``True``. These files are stored in the ``CACHE_PATH`` ``True``. These files are stored in the ``CACHE_PATH`` directory. If the
directory. If the file has no record in the cache file, it is read file has no record in the cache file, it is read as usual.
as usual.
2. The file is checked according to ``CHECK_MODIFIED_METHOD``: 2. The file is checked according to ``CHECK_MODIFIED_METHOD``:
- If set to ``'mtime'``, the modification time of the file is - If set to ``'mtime'``, the modification time of the file is
@ -1305,47 +1312,45 @@ When Pelican is about to read some content source file:
- If set to a name of a function provided by the ``hashlib`` - If set to a name of a function provided by the ``hashlib``
module, e.g. ``'md5'``, the file hash is checked. module, e.g. ``'md5'``, the file hash is checked.
- If set to anything else or the necessary information about the - If set to anything else or the necessary information about the
file cannot be found in the cache file, the content is read as file cannot be found in the cache file, the content is read as usual.
usual.
3. If the file is considered unchanged, the content data saved in a 3. If the file is considered unchanged, the content data saved in a
previous build corresponding to the file is loaded from the cache, previous build corresponding to the file is loaded from the cache, and the
and the file is not read. file is not read.
4. If the file is considered changed, the file is read and the new 4. If the file is considered changed, the file is read and the new
modification information and the content data are saved to the modification information and the content data are saved to the cache if
cache if ``CACHE_CONTENT`` is ``True``. ``CACHE_CONTENT`` is ``True``.
If ``CONTENT_CACHING_LAYER`` is set to ``'reader'`` (the default), If ``CONTENT_CACHING_LAYER`` is set to ``'reader'`` (the default), the raw
the raw content and metadata returned by a reader are cached. If this content and metadata returned by a reader are cached. If this setting is
setting is instead set to ``'generator'``, the processed content instead set to ``'generator'``, the processed content object is cached. Caching
object is cached. Caching the processed content object may conflict the processed content object may conflict with plugins (as some reading related
with plugins (as some reading related signals may be skipped) and the signals may be skipped) and the ``WITH_FUTURE_DATES`` functionality (as the
``WITH_FUTURE_DATES`` functionality (as the ``draft`` status of the ``draft`` status of the cached content objects would not change automatically
cached content objects would not change automatically over time). over time).
Checking modification times is faster than comparing file hashes, Checking modification times is faster than comparing file hashes, but it is not
but it is not as reliable because ``mtime`` information can be lost, as reliable because ``mtime`` information can be lost, e.g., when copying
e.g., when copying content source files using the ``cp`` or ``rsync`` content source files using the ``cp`` or ``rsync`` commands without the
commands without the ``mtime`` preservation mode (which for ``rsync`` ``mtime`` preservation mode (which for ``rsync`` can be invoked by passing the
can be invoked by passing the ``--archive`` flag). ``--archive`` flag).
The cache files are Python pickles, so they may not be readable by The cache files are Python pickles, so they may not be readable by different
different versions of Python as the pickle format often changes. If versions of Python as the pickle format often changes. If such an error is
such an error is encountered, it is caught and the cache file is encountered, it is caught and the cache file is rebuilt automatically in the
rebuilt automatically in the new format. The cache files will also be new format. The cache files will also be rebuilt after the ``GZIP_CACHE``
rebuilt after the ``GZIP_CACHE`` setting has been changed. setting has been changed.
The ``--ignore-cache`` command-line option is useful when the The ``--ignore-cache`` command-line option is useful when the whole cache needs
whole cache needs to be regenerated, such as when making modifications to be regenerated, such as when making modifications to the settings file that
to the settings file that will affect the cached content, or just for will affect the cached content, or just for debugging purposes. When Pelican
debugging purposes. When Pelican runs in autoreload mode, modification runs in autoreload mode, modification of the settings file will make it ignore
of the settings file will make it ignore the cache automatically if the cache automatically if ``AUTORELOAD_IGNORE_CACHE`` is ``True``.
``AUTORELOAD_IGNORE_CACHE`` is ``True``.
Note that even when using cached content, all output is always Note that even when using cached content, all output is always written, so the
written, so the modification times of the generated ``*.html`` files modification times of the generated ``*.html`` files will always change.
will always change. Therefore, ``rsync``-based uploading may benefit Therefore, ``rsync``-based uploading may benefit from the ``--checksum``
from the ``--checksum`` option. option.
.. _writing_only_selected_content: .. _writing_only_selected_content:
@ -1353,16 +1358,14 @@ from the ``--checksum`` option.
Writing only selected content Writing only selected content
============================= =============================
When only working on a single article or page, or making tweaks to When only working on a single article or page, or making tweaks to your theme,
your theme, it is often desirable to generate and review your work it is often desirable to generate and review your work as quickly as possible.
as quickly as possible. In such cases, generating and writing the In such cases, generating and writing the entire site output is often
entire site output is often unnecessary. By specifying only the unnecessary. By specifying only the desired files as output paths in the
desired files as output paths in the ``WRITE_SELECTED`` list, ``WRITE_SELECTED`` list, **only** those files will be written. This list can be
**only** those files will be written. This list can be also specified also specified on the command line using the ``--write-selected`` option, which
on the command line using the ``--write-selected`` option, which accepts a comma-separated list of output file paths. By default this list is
accepts a comma-separated list of output file paths. By default this empty, so all output is written. See :ref:`site_generation` for more details.
list is empty, so all output is written. See :ref:`site_generation` for
more details.
Example settings Example settings

View file

@ -3,13 +3,14 @@
Creating themes Creating themes
############### ###############
To generate its HTML output, Pelican uses the `Jinja <http://jinja.pocoo.org/>`_ To generate its HTML output, Pelican uses the `Jinja
templating engine due to its flexibility and straightforward syntax. If you want <http://jinja.pocoo.org/>`_ templating engine due to its flexibility and
to create your own theme, feel free to take inspiration from the `"simple" theme straightforward syntax. If you want to create your own theme, feel free to take
inspiration from the `"simple" theme
<https://github.com/getpelican/pelican/tree/master/pelican/themes/simple/templates>`_. <https://github.com/getpelican/pelican/tree/master/pelican/themes/simple/templates>`_.
To generate your site using a theme you have created (or downloaded manually and To generate your site using a theme you have created (or downloaded manually
then modified), you can specify that theme via the ``-t`` flag:: and then modified), you can specify that theme via the ``-t`` flag::
pelican content -s pelicanconf.py -t /projects/your-site/themes/your-theme pelican content -s pelicanconf.py -t /projects/your-site/themes/your-theme
@ -42,9 +43,9 @@ To make your own theme, you must follow the following structure::
`theme` folder. The above filesystem layout includes CSS and image folders, `theme` folder. The above filesystem layout includes CSS and image folders,
but those are just examples. Put what you need here. but those are just examples. Put what you need here.
* `templates` contains all the templates that will be used to generate the content. * `templates` contains all the templates that will be used to generate the
The template files listed above are mandatory; you can add your own templates content. The template files listed above are mandatory; you can add your own
if it helps you keep things organized while creating your theme. templates if it helps you keep things organized while creating your theme.
.. _templates-variables: .. _templates-variables:
@ -93,13 +94,13 @@ draft_pages The list of draft pages
Sorting Sorting
------- -------
URL wrappers (currently categories, tags, and authors), have URL wrappers (currently categories, tags, and authors), have comparison methods
comparison methods that allow them to be easily sorted by name:: that allow them to be easily sorted by name::
{% for tag, articles in tags|sort %} {% for tag, articles in tags|sort %}
If you want to sort based on different criteria, `Jinja's sort If you want to sort based on different criteria, `Jinja's sort command`__ has a
command`__ has a number of options. number of options.
__ http://jinja.pocoo.org/docs/templates/#sort __ http://jinja.pocoo.org/docs/templates/#sort
@ -108,13 +109,12 @@ Date Formatting
--------------- ---------------
Pelican formats the date according to your settings and locale Pelican formats the date according to your settings and locale
(``DATE_FORMATS``/``DEFAULT_DATE_FORMAT``) and provides a (``DATE_FORMATS``/``DEFAULT_DATE_FORMAT``) and provides a ``locale_date``
``locale_date`` attribute. On the other hand, the ``date`` attribute will attribute. On the other hand, the ``date`` attribute will be a `datetime`_
be a `datetime`_ object. If you need custom formatting for a date object. If you need custom formatting for a date different than your settings,
different than your settings, use the Jinja filter ``strftime`` use the Jinja filter ``strftime`` that comes with Pelican. Usage is same as
that comes with Pelican. Usage is same as Python `strftime`_ format, Python `strftime`_ format, but the filter will do the right thing and format
but the filter will do the right thing and format your date according your date according to the locale given in your settings::
to the locale given in your settings::
{{ article.date|strftime('%d %B %Y') }} {{ article.date|strftime('%d %B %Y') }}
@ -127,7 +127,8 @@ index.html
This is the home page or index of your blog, generated at ``index.html``. This is the home page or index of your blog, generated at ``index.html``.
If pagination is active, subsequent pages will reside in ``index{number}.html``. If pagination is active, subsequent pages will reside in
``index{number}.html``.
====================== =================================================== ====================== ===================================================
Variable Description Variable Description
@ -153,8 +154,8 @@ page_name 'index' -- useful for pagination links
author.html author.html
------------- -------------
This template will be processed for each of the existing authors, with This template will be processed for each of the existing authors, with output
output generated according to the ``AUTHOR_SAVE_AS`` setting (`Default:` generated according to the ``AUTHOR_SAVE_AS`` setting (`Default:`
``author/{slug}.html``). If pagination is active, subsequent pages will by ``author/{slug}.html``). If pagination is active, subsequent pages will by
default reside at ``author/{slug}{number}.html``. default reside at ``author/{slug}{number}.html``.
@ -221,10 +222,9 @@ page_name CATEGORY_URL where everything after `{slug}` is
article.html article.html
------------- -------------
This template will be processed for each article, with This template will be processed for each article, with output generated
output generated according to the ``ARTICLE_SAVE_AS`` setting (`Default:` according to the ``ARTICLE_SAVE_AS`` setting (`Default:` ``{slug}.html``). The
``{slug}.html``). The following variables are available when following variables are available when rendering.
rendering.
============= =================================================== ============= ===================================================
Variable Description Variable Description
@ -233,9 +233,9 @@ article The article object to be displayed
category The name of the category for the current article category The name of the category for the current article
============= =================================================== ============= ===================================================
Any metadata that you put in the header of the article source file Any metadata that you put in the header of the article source file will be
will be available as fields on the ``article`` object. The field name will be available as fields on the ``article`` object. The field name will be the same
the same as the name of the metadata field, except in all-lowercase characters. as the name of the metadata field, except in all-lowercase characters.
For example, you could add a field called `FacebookImage` to your article For example, you could add a field called `FacebookImage` to your article
metadata, as shown below: metadata, as shown below:
@ -251,8 +251,8 @@ metadata, as shown below:
FacebookImage: http://franciscabrel.com/images/pythonlove.png FacebookImage: http://franciscabrel.com/images/pythonlove.png
This new metadata will be made available as `article.facebookimage` in your This new metadata will be made available as `article.facebookimage` in your
`article.html` template. This would allow you, for example, to specify an `article.html` template. This would allow you, for example, to specify an image
image for the Facebook open graph tags that will change for each article: for the Facebook open graph tags that will change for each article:
.. code-block:: html+jinja .. code-block:: html+jinja
@ -262,10 +262,9 @@ image for the Facebook open graph tags that will change for each article:
page.html page.html
--------- ---------
This template will be processed for each page, with This template will be processed for each page, with output generated according
output generated according to the ``PAGE_SAVE_AS`` setting (`Default:` to the ``PAGE_SAVE_AS`` setting (`Default:` ``pages/{slug}.html``). The
``pages/{slug}.html``). The following variables are available when following variables are available when rendering.
rendering.
============= =================================================== ============= ===================================================
Variable Description Variable Description
@ -278,10 +277,10 @@ page The page object to be displayed. You can access its
tag.html tag.html
-------- --------
This template will be processed for each tag, with This template will be processed for each tag, with output generated according
output generated according to the ``TAG_SAVE_AS`` setting (`Default:` to the ``TAG_SAVE_AS`` setting (`Default:` ``tag/{slug}.html``). If pagination
``tag/{slug}.html``). If pagination is active, subsequent pages will by is active, subsequent pages will by default reside at
default reside at ``tag/{slug}{number}.html``. ``tag/{slug}{number}.html``.
====================== =================================================== ====================== ===================================================
Variable Description Variable Description
@ -312,9 +311,9 @@ page_name TAG_URL where everything after `{slug}` is removed
period_archives.html period_archives.html
-------------------- --------------------
This template will be processed for each year of your posts if a path This template will be processed for each year of your posts if a path for
for ``YEAR_ARCHIVE_SAVE_AS`` is defined, each month if ``MONTH_ARCHIVE_SAVE_AS`` ``YEAR_ARCHIVE_SAVE_AS`` is defined, each month if ``MONTH_ARCHIVE_SAVE_AS`` is
is defined, and each day if ``DAY_ARCHIVE_SAVE_AS`` is defined. defined, and each day if ``DAY_ARCHIVE_SAVE_AS`` is defined.
=================== =================================================== =================== ===================================================
Variable Description Variable Description
@ -464,9 +463,9 @@ Since version 3.0, Pelican supports inheritance from the ``simple`` theme, so
you can re-use the ``simple`` theme templates in your own themes. you can re-use the ``simple`` theme templates in your own themes.
If one of the mandatory files in the ``templates/`` directory of your theme is If one of the mandatory files in the ``templates/`` directory of your theme is
missing, it will be replaced by the matching template from the ``simple`` theme. missing, it will be replaced by the matching template from the ``simple``
So if the HTML structure of a template in the ``simple`` theme is right for you, theme. So if the HTML structure of a template in the ``simple`` theme is right
you don't have to write a new template from scratch. for you, you don't have to write a new template from scratch.
You can also extend templates from the ``simple`` theme in your own themes by You can also extend templates from the ``simple`` theme in your own themes by
using the ``{% extends %}`` directive as in the following example: using the ``{% extends %}`` directive as in the following example:

View file

@ -8,8 +8,8 @@ Custom 404 Pages
When a browser requests a resource that the web server cannot find, the web When a browser requests a resource that the web server cannot find, the web
server usually displays a generic "File not found" (404) error page that can be server usually displays a generic "File not found" (404) error page that can be
stark and unsightly. One way to provide an error page that matches the theme stark and unsightly. One way to provide an error page that matches the theme of
of your site is to create a custom 404 page (*not* an article), such as this your site is to create a custom 404 page (*not* an article), such as this
Markdown-formatted example stored in ``content/pages/404.md``:: Markdown-formatted example stored in ``content/pages/404.md``::
Title: Not Found Title: Not Found
@ -29,8 +29,8 @@ For Apache::
ErrorDocument 404 /404.html ErrorDocument 404 /404.html
For Amazon S3, first navigate to the ``Static Site Hosting`` menu in the For Amazon S3, first navigate to the ``Static Site Hosting`` menu in the bucket
bucket settings on your AWS cosole. From there:: settings on your AWS cosole. From there::
Error Document: 404.html Error Document: 404.html
@ -67,15 +67,17 @@ already exist). The ``git push origin gh-pages`` command updates the remote
``gh-pages`` branch, effectively publishing the Pelican site. ``gh-pages`` branch, effectively publishing the Pelican site.
.. note:: .. note::
The ``github`` target of the Makefile (and the ``gh_pages`` task of ``tasks.py``)
created by the ``pelican-quickstart`` command The ``github`` target of the Makefile (and the ``gh_pages`` task of
publishes the Pelican site as Project Pages, as described above. ``tasks.py``) created by the ``pelican-quickstart`` command publishes the
Pelican site as Project Pages, as described above.
.. note:: ghp-import on Windows .. note:: ghp-import on Windows
Until `ghp-import Pull Request #25 <https://github.com/davisp/ghp-import/pull/25>`_ Until `ghp-import Pull Request #25
is accepted, you will need to install a custom build of ghp-import: <https://github.com/davisp/ghp-import/pull/25>`_ is accepted, you will need
``pip install https://github.com/chevah/ghp-import/archive/win-support.zip`` to install a custom build of ghp-import: ``pip install
https://github.com/chevah/ghp-import/archive/win-support.zip``
User Pages User Pages
---------- ----------
@ -99,13 +101,17 @@ by the ``ghp-import`` command) to the ``elemoine.github.io`` repository's
To publish your Pelican site as User Pages, feel free to adjust the To publish your Pelican site as User Pages, feel free to adjust the
``github`` target of the Makefile. ``github`` target of the Makefile.
Another option for publishing to User Pages is to generate the output files in the root directory of the project. Another option for publishing to User Pages is to generate the output files in
the root directory of the project.
For example, your main project folder is ``<username>.github.io`` and you can create the Pelican project in a subdirectory called ``Pelican``. Then from inside the ``Pelican`` folder you can run:: For example, your main project folder is ``<username>.github.io`` and you can
create the Pelican project in a subdirectory called ``Pelican``. Then from
inside the ``Pelican`` folder you can run::
$ pelican content -o .. -s pelicanconf.py $ pelican content -o .. -s pelicanconf.py
Now you can push the whole project ``<username>.github.io`` to the master branch of your GitHub repository:: Now you can push the whole project ``<username>.github.io`` to the master
branch of your GitHub repository::
$ git push origin master $ git push origin master
@ -120,8 +126,8 @@ relevant `GitHub docs <https://help.github.com/articles/custom-404-pages/>`_.
Update your site on each commit Update your site on each commit
------------------------------- -------------------------------
To automatically update your Pelican site on each commit, you can create To automatically update your Pelican site on each commit, you can create a
a post-commit hook. For example, you can add the following to post-commit hook. For example, you can add the following to
``.git/hooks/post-commit``:: ``.git/hooks/post-commit``::
pelican content -o output -s pelicanconf.py && ghp-import output && git push origin gh-pages pelican content -o output -s pelicanconf.py && ghp-import output && git push origin gh-pages
@ -142,8 +148,8 @@ output directory. For example::
Note: use forward slashes, ``/``, even on Windows. Note: use forward slashes, ``/``, even on Windows.
You can also use the ``EXTRA_PATH_METADATA`` mechanism You can also use the ``EXTRA_PATH_METADATA`` mechanism to place a
to place a ``favicon.ico`` or ``robots.txt`` at the root of any site. ``favicon.ico`` or ``robots.txt`` at the root of any site.
How to add YouTube or Vimeo Videos How to add YouTube or Vimeo Videos
================================== ==================================