PELICAN(1)
pelican β PELICAN(1) π β¨
okay bestie, buckle up β this is the manual page for <pink>pelican</pink>, and yes, itβs giving extremely useful. π¦
β¨ NAME β¨
Okay so <pink>Pelican</pink> is a static site generator written in Python (https://www.python.org/). Highlights include:
- Write your content directly with your editor of choice in reStructuredText (
http://docutils.sourceforge.net/rst.html) or Markdown (https://daringfireball.net/projects/markdown/) formats - Includes a simple CLI tool to (re)generate your site
- Easy to interface with distributed version control systems and web hooks
- Completely static output is easy to host anywhere
Ready to get started? Check out the Quickstart <> guide. π
πΈ FEATURES πΈ
Pelicanβs feature highlights include:
- Articles (e.g., blog posts) and pages (e.g.,
"About","Projects","Contact") - Integration with external services
- Site themes (created using Jinja2 (
https://palletsprojects.com/p/jinja/) templates) - Publication of articles in multiple languages
- Generation of Atom and RSS feeds
- Code syntax highlighting
- Import existing content from WordPress, Dotclear, or RSS feeds
- Fast rebuild times thanks to content caching and selective output writing
- Extensible via a rich plugin ecosystem: Pelican Plugins (
https://github.com/pelican-plugins)
π WHY THE NAME PELICAN ? π
"Pelican" is an anagram for calepin, which means "notebook" in French. ;) β iconic, honestly. π
π¦ SOURCE CODE π¦
You can access the source code at: https://github.com/getpelican/pelican π
π HOW TO GET HELP, CONTRIBUTE, OR PROVIDE FEEDBACK π
See our feedback and contribution submission guidelines <>. π«Ά
π DOCUMENTATION π
β¨ Quickstart β¨
Reading through all the documentation is highly recommended, but for the truly impatient, following are some quick steps to get started. No cap, this is the speedy route. β
π Installation π
Install Pelican (and optionally Markdown if you intend to use it) on Python >=3.11 by running the following command in your preferred terminal, prefixing with sudo if permissions warrant:
python -m pip install "pelican[markdown]"
π§ Create a project π§
First, choose a name for your project, create an appropriately-named directory for your site, and switch to that directory:
mkdir -p ~/projects/yoursite
cd ~/projects/yoursite
Create a skeleton project via the pelican-quickstart command, which begins by asking some questions about your site:
pelican-quickstart
For questions that have default values denoted in brackets, feel free to use the Return key to accept those default values [1]. When asked for your URL prefix, enter your domain name as indicated (e.g., https://example.com). π
π Create an article π
You cannot run Pelican until you have created some content. Use your preferred text editor to create your first article with the following content:
Title: My First Review
Date: 2010-12-03 10:20
Category: Review
Following is a review of my favorite mechanical keyboard.
Given that this example article is in Markdown format, save it as ~/projects/yoursite/content/keyboard-review.md. π
π₯ Generate your site π₯
From your project root directory, run the pelican command to generate your site:
pelican content
Your site has now been generated inside the output/ directory. β¨
You may see a warning related to feeds, but that is normal when developing locally and can be ignored for now. π
π Preview your site π
Open a new terminal session, navigate to your project root directory, and run the following command to launch Pelicanβs web server:
pelican --listen
Preview your site by navigating to http://localhost:8000/ in your browser. π
Continue reading the other documentation sections for more detail, and check out the Pelican wikiβs Tutorials (https://github.com/getpelican/pelican/wiki/Tutorials) page for links to community-published tutorials. π¦
π Footnotes π
[1]You can help localize default fields by installing the optional tzlocal (https://pypi.org/project/tzlocal/) module.
π Installing Pelican π
Pelican currently runs best on Python >=3.11; earlier versions of Python are not supported. π¨
Once Pelican is installed, you can run pelican --help to see basic usage options. For more detail, refer to the Publish <> section.
You can install Pelican via several different methods. Pick your fighter. β
Recommended method: Pip (https://pip.pypa.io/) User Install
To install Pelican via Pip:
python3 -m pip install --user "pelican[markdown]"
Or, if you do not plan to use Markdown (https://pypi.org/project/Markdown/), you can omit the [markdown] suffix:
python3 -m pip install --user pelican
Alternate method 1: Pipx (https://github.com/pypa/pipx)
Pipx lets you execute binaries from Python packages in isolated environments. You can install Pipx by following its documentation (https://pipx.pypa.io). After Pipx is installed, you can install Pelican via:
pipx install "pelican[markdown]"
Alternate method 2: uv (https://docs.astral.sh/uv/)
Like Pipx, uv allows you to install tools in isolated environments. If you have uv installed, you can install Pelican via:
uv tool install "pelican[markdown]"
Alternate method 3: Virtual Environment
If you prefer to manually manage a virtual environment, you can create a virtual environment for Pelican via venv (https://docs.python.org/3/library/venv.html) before installing Pelican:
python3 -m venv ~/virtualenvs/pelican
source ~/virtualenvs/pelican/bin/activate
python3 -m pip install "pelican[markdown]"
Alternatively, if you have the project source, you can replace the last command with the following to install Pelican using the setuptools method:
cd path-to-Pelican-source
python3 -m pip install .
If you have Git installed and prefer to install the latest bleeding-edge version of Pelican rather than a stable release, use the following command:
python3 -m pip install -e "git+https://github.com/getpelican/pelican.git#egg=pelican"
To exit the virtual environment, type deactivate. π«Ά
π¦ Optional packages π¦
If you plan on using Markdown (https://pypi.org/project/Markdown/) as a markup format, you can install Pelican with Markdown support:
python3 -m pip install --user "pelican[markdown]"
Typographical enhancements can be enabled in your settings file, but first the requisite Typogrify (https://github.com/justinmayer/typogrify) library must be installed:
python3 -m pip install --user typogrify
If you are using Pipx, you can inject packages into the Pipx-managed virtual environment. For example, to add Typogrify:
pipx inject pelican typogrify
To use uv to install Pelican with additional extra packages, use the following example command, which like above will also install Typogrify:
uv tool install --with typogrify "pelican[markdown]"
π Dependencies π
When Pelican is installed, the following dependent Python packages should be automatically installed without any action on your part:
- feedgenerator (
https://pypi.org/project/feedgenerator/), to generate the Atom feeds - jinja2 (
https://pypi.org/project/Jinja2/), for templating support - pygments (
https://pypi.org/project/Pygments/), for syntax highlighting - docutils (
https://pypi.org/project/docutils/), for supporting reStructuredText as an input format - blinker (
https://pypi.org/project/blinker/), an object-to-object and broadcast signaling system - unidecode (
https://pypi.org/project/Unidecode/), for ASCII transliterations of Unicode text utilities - MarkupSafe (
https://pypi.org/project/MarkupSafe/), for a markup-safe string implementation - python-dateutil (
https://pypi.org/project/python-dateutil/), to read the date metadata
π Upgrading π
If you installed a stable Pelican release via Pip (https://pip.pypa.io/) and wish to upgrade to the latest stable release, you can do so by adding --upgrade:
python3 -m pip install --upgrade pelican
If you installed Pelican via setuptools or the bleeding-edge method, perform the same step to install the most recent version.
If you installed with Pipx, upgrade via:
pipx upgrade pelican
If you installed with uv, upgrade via:
uv tool upgrade pelican
π Kickstart your site π
Once Pelican has been installed, you can create a skeleton project via the pelican-quickstart command, which begins by asking some questions about your site:
pelican-quickstart
If run inside an activated virtual environment, pelican-quickstart will look for an associated project path inside $VIRTUAL_ENV/.project. If that file exists and contains a valid directory path, the new Pelican project will be saved at that location. Otherwise, the default is the current working directory. To set the new project path on initial invocation, use: pelican-quickstart --path /your/desired/directory
Once you finish answering all the questions, your project will consist of the following hierarchy (except for pages β shown in parentheses below β which you can optionally add yourself if you plan to create non-chronological content):
yourproject/
βββ content
β βββ (pages)
βββ output
βββ tasks.py
βββ Makefile
βββ pelicanconf.py # Main settings file
βββ publishconf.py # Settings to use when ready to publish
The next step is to begin to adding content to the content folder that has been created for you. π«Ά
β¨ Writing content β¨
π¦ Articles and pages π¦
Pelican considers "articles" to be chronological content, such as posts on a blog, and thus associated with a date. π
The idea behind "pages" is that they are usually not temporal in nature and are used for content that does not change very often (e.g., "About" or "Contact" pages).
You can find sample content in the repository at samples/content/. π
π File metadata π
Pelican tries to be smart enough to get the information it needs from the file system (for instance, about the category of your articles), but some information you need to provide in the form of metadata inside your files. π§ β¨
If you are writing your content in reStructuredText format, you can provide this metadata in text files via the following syntax (give your file the .rst extension):
My super title
##############
:date: 2010-10-03 10:20
:modified: 2010-10-04 18:40
:tags: thats, awesome
:category: yeah
:slug: my-super-post
:authors: Alexis Metaireau, Conan Doyle
:summary: Short version for index and feeds
Author and tag lists may be semicolon-separated instead, which allows you to write authors and tags containing commas:
:tags: pelican, publishing tool; pelican, bird
:authors: Metaireau, Alexis; Doyle, Conan
okay so Pelican also ships an extension to reStructuredText that gives you the abbr HTML tag. To use it, you literally just write something like this in your post:
This will be turned into :abbr:`HTML (HyperText Markup Language)`.
You can also do the whole Markdown thing (file ending in .md, .markdown, .mkd, or .mdown). Heads up tho β Markdown generation requires that you first explicitly install the Python-Markdown package (https://github.com/Python-Markdown/markdown), and you do that with pip install Markdown. π
Pelican also supports Markdown Extensions (https://python-markdown.github.io/extensions/), which might have to be installed separately if they're not included in the default Markdown package β and you configure and load them via the MARKDOWN setting. β¨
Metadata syntax for Markdown posts should follow this pattern:
Title: My super title
Date: 2010-12-03 10:20
Modified: 2010-12-05 19:30
Category: Python
Tags: pelican, publishing
Slug: my-super-post
Authors: Alexis Metaireau, Conan Doyle
Summary: Short version for index and feeds
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 the reserved metadata keywords, bestie β that's the vibe check) for use in your templates. The following list contains a list of reserved metadata keywords π:
titleβ Title of the article or pagedateβ Publication date (e.g.,YYYY-MM-DD HH:SS)modifiedβ Modification date (e.g.,YYYY-MM-DD HH:SS)tagsβ Content tags, separated by commaskeywordsβ Content keywords, separated by commas (HTML content only)categoryβ Content category (one only β not multiple)slugβ Identifier used in URLs and translationsauthorβ Content author, when there is only oneauthorsβ Content authors, when there are multiplesummaryβ Brief description of content for index pageslangβ Content language ID (en,fr, etc.)translationβ If content is a translation of another (trueorfalse)statusβ Content status:draft,hidden,skip, orpublishedtemplateβ Name of template to use to generate content (without extension)save_asβ Save content to this relative file pathurlβ URL to use for this article/page
Readers for additional formats (such as AsciiDoc, https://asciidoc.org) are available via plugins, which you can find via the Pelican Plugins collection (https://github.com/pelican-plugins) as well as the legacy pelican-plugins repository (https://github.com/getpelican/pelican-plugins). π¦
Pelican can also process HTML files ending in .html and .htm. It interprets the HTML in a very straightforward manner β reading metadata from meta tags, the title from the title tag, and the body out from the body tag:
<html>
<head>
<title>My super title</title>
<meta name="tags" content="thats, awesome" />
<meta name="date" content="2012-07-09 22:28" />
<meta name="modified" content="2012-07-10 20:14" />
<meta name="category" content="yeah" />
<meta name="authors" content="Alexis MΓ©taireau, Conan Doyle" />
<meta name="summary" content="Short version for index and feeds" />
</head>
<body>
This is the content of my super blog post.
</body>
</html>
With HTML, there is one simple exception to the standard metadata: tags can be specified either via the tags metadata, as is standard in Pelican, or via the keywords metadata, as is standard in HTML. The two can be used interchangeably. π«Ά
Note that, aside from the title, none of this content metadata is mandatory β like, the title is the main character here. If the date is not specified and DEFAULT_DATE is set to 'fs', Pelican will rely on the file's "mtime" timestamp, and the category can be determined by the directory in which the file resides. For example, a file located at python/foobar/myfoobar.rst will have a category of foobar. If you would like to organize your files in other ways where the name of the subfolder would not be a good category name, you can set the setting USE_FOLDER_AS_CATEGORY to False. When parsing dates given in the page metadata, Pelican supports the W3C's suggested subset ISO 8601 (https://www.w3.org/TR/NOTE-datetime). π
So the title is the only required metadata. If that bothers you, worry not β instead of manually specifying a title in your metadata each time, you can use the source content file name as the title. For example, a Markdown source file named Publishing via Pelican.md would automatically be assigned a title of Publishing via Pelican. If you'd prefer this behavior, add the following line to your settings file:
FILENAME_METADATA = '(?P<title>.*)'
Note: when experimenting with different settings (especially the metadata ones) caching may interfere and the changes may not be visible π. In such cases disable caching withLOAD_CONTENT_CACHE = Falseor use the--ignore-cachecommand-line switch.
modified should be the last time you updated the article, and defaults to date if not specified. Besides, you can show modified in the templates, and 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 can use the author field.
If you do not explicitly specify summary metadata for a given post, the SUMMARY_MAX_LENGTH setting can be used to specify how many words from the beginning of an article are used as the summary. You can also use an article's first N paragraphs as its summary using the SUMMARY_MAX_PARAGRAPHS setting. If both settings are in use, the specified number of paragraphs will be used but may be truncated to respect the specified maximum length. β¨
You can also extract any metadata from the filename through a regular expression to be set in the FILENAME_METADATA setting. All named groups that are matched will be set in the metadata object. The default value for the FILENAME_METADATA setting will only extract the date from the filename. For example, if you would like to extract both the date and the slug, you could set something like: '(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'
Please note that the metadata available inside your files takes precedence over the metadata extracted from the filename. π
π¦ Pages π¦
If you create a folder named pages inside the content folder, all the files in it will be used to generate static pages, such as About or Contact pages. (See example filesystem layout below β iykyk π.)
You can use the DISPLAY_PAGES_ON_MENU setting to control whether all those pages are displayed in the primary navigation menu. (Default is True.) πΈ
So, if you want to exclude any pages from being linked to or listed in the menu, bestie, just add a status: hidden attribute to its metadata. This is lowkey useful for things like making error pages that fit the generated theme of your site. π
π Static content π
Static files are files other than articles and pages that are copied to the output folder as-is, without processing. You can control which static files are copied over with the STATIC_PATHS setting of the project's pelicanconf.py file. Pelican's default configuration includes the images directory for this, but others must be added manually. In addition, static files that are explicitly linked to are included (see below). β¨
Note: In the default configuration, all files with a valid content file suffix (.html,.rst,.md, ...) get processed by the article and page generators before the static generator. This is avoided by altering the*_EXCLUDEsettings appropriately. π«Ά
π¦ Mixed content in the same directory π¦
Starting with Pelican 3.5, static files can safely share a source directory with page source files, without exposing the page sources in the generated site. Any such directory must be added to both STATIC_PATHS and PAGE_PATHS (or STATIC_PATHS and ARTICLE_PATHS). Pelican will identify and process the page source files normally, and copy the remaining files as if they lived in a separate directory reserved for static files. No cap. π§
Note: Placing static and content source files together in the same source directory does not guarantee that they will end up in the same place in the generated site. The easiest way to do this is by using the{attach}link syntax (described below). Alternatively, theSTATIC_SAVE_AS,PAGE_SAVE_AS, andARTICLE_SAVE_ASsettings (and the corresponding*_URLsettings) can be configured to place files of different types together, just as they could in earlier versions of Pelican. πΈ
β¨ Linking to internal content β¨
From Pelican 3.1 onwards, it is now possible to specify intra-site links to files in the source content hierarchy instead of files in the generated hierarchy. This makes it easier to link from the current post to other content that may be sitting alongside that post (instead of having to determine where the other content will be placed after site generation). It's giving main character energy for your links. π
To link to internal content (files in the content directory), use the following syntax for the link target: {filename}path/to/file.
Note: forward slashes,/, are the required path separator in the{filename}directive on all operating systems, including Windows. π«‘
For example, a Pelican project might be structured like this:
website/
βββ content
β βββ category/
β β βββ article1.rst
β βββ article2.md
β βββ pages
β βββ about.md
βββ pelican.conf.py
In this example, article1.rst could look like this:
The first article
#################
:date: 2012-12-01 10:02
See below intra-site link examples in reStructuredText format.
`a link relative to the current file <{filename}../article2.md>`_
`a link relative to the content root <{filename}/article2.md>`_
and article2.md:
Title: The second article
Date: 2012-12-01 10:02
See below intra-site link examples in Markdown format.
[a link relative to the current file]({filename}category/article1.rst)
[a link relative to the content root]({filename}/category/article1.rst)
π Linking to static files π
You can link to static content using {static}path/to/file. Files linked to with this syntax will automatically be copied to the output directory, even if the source directories containing them are not included in the STATIC_PATHS setting of the project's pelicanconf.py file. Obsessed with the convenience, honestly. π
For example, a project's content directory might be structured like this:
content
βββ images
β βββ han.jpg
βββ pdfs
β βββ menu.pdf
βββ pages
βββ test.md
test.md would include:

[Our Menu]({static}/pdfs/menu.pdf)
Site generation would then copy han.jpg to output/images/han.jpg, menu.pdf to output/pdfs/menu.pdf, and write the appropriate links in test.md. Slay. β¨
If you use {static} to link to an article or a page, this will be turned into a link to its source code. π
π Attaching static files π
Starting with Pelican 3.5, static files can be "attached" to a page or article using this syntax for the link target: {attach}path/to/file. This works like the {static} syntax, but also relocates the static file into the linking document's output directory. If the static file originates from a subdirectory beneath the linking document's source, that relationship will be preserved on output. Otherwise, it will become a sibling of the linking document. π¦
This only works for linking to static files.
For example, a project's content directory might be structured like this:
content
βββ blog
β βββ icons
β β βββ icon.png
β βββ photo.jpg
β βββ testpost.md
βββ downloads
βββ archive.zip
pelicanconf.py would include:
PATH = 'content'
ARTICLE_PATHS = ['blog']
ARTICLE_SAVE_AS = '{date:%Y}/{slug}.html'
ARTICLE_URL = '{date:%Y}/{slug}.html'
testpost.md would include:
Title: Test Post
Category: test
Date: 2014-10-31


[Downloadable File]({attach}/downloads/archive.zip)
Site generation would then produce an output directory structured like this:
output
βββ 2014
βββ archive.zip
βββ icons
β βββ icon.png
βββ photo.jpg
βββ test-post.html
Notice that all the files linked using {attach} ended up in or beneath the article's output directory. Cute, right? π₯°
If a static file is linked multiple times, the relocating feature of {attach} will only work in the first of those links to be processed. After the first link, Pelican will treat {attach} like {static}. This avoids breaking the already-processed links.
Be careful when linking to a file from multiple documents: Since the first link to a file finalizes its location and Pelican does not define the order in which documents are processed, using{attach}on a file linked by multiple documents can cause its location to change from one site build to the next. (Whether this happens in practice will depend on the operating system, file system, version of Pelican, and documents being added, modified, or removed from the project.) Any external sites linking to the file's old location might then find their links broken. It is therefore advisable to use{attach}only if you use it in all links to a file, and only if the linking documents share a single directory. Under these conditions, the file's output location will not change in future builds. In cases where these precautions are not possible, consider using{static}links instead of{attach}, and letting the file's location be determined by the project'sSTATIC_SAVE_ASandSTATIC_URLsettings. (Per-filesave_asandurloverrides can still be set inEXTRA_PATH_METADATA.) π periodt.
Note: When using{attach}, any parent directory in*_URL/*_SAVE_ASsettings should match each other. See also:URL settings <#url-settings>π
πΈ Linking to authors, categories, index and tags πΈ
You can link to authors, categories, index and tags using the {author}name, {category}foobar, {index} and {tag}tagname syntax. iykyk. π«Ά
π Deprecated internal link syntax π
To remain compatible with earlier versions, Pelican still supports vertical bars (||) in addition to curly braces ({}) for internal links. For example: |filename|an_article.rst, |tag|tagname, |category|foobar. The syntax was changed from || to {} to avoid collision with Markdown extensions or reST directives. Similarly, Pelican also still supports linking to static content with {filename}. The syntax was changed to {static} to allow linking to both generated articles and pages and their static sources. π
Support for the old syntax may eventually be removed.
π§ Including other files π§
Both Markdown and reStructuredText syntaxes provide mechanisms for this.
Following below are some examples for reStructuredText using the include directive (http://docutils.sourceforge.net/docs/ref/rst/directives.html#include):
.. include:: file.rst
Include a fragment of a file delimited by two identifiers, highlighted as C++ (slicing based on line numbers is also possible):
.. include:: main.cpp
:code: c++
:start-after: // begin
:end-before: // end
Include a raw HTML file (or an inline SVG) and put it directly into the output without any processing:
.. raw:: html
:file: table.html
For Markdown, one must rely on an extension. For example, using the mdx_include plugin (https://github.com/neurobin/mdx_include):
{! template.html !}
β Importing an existing site β
It is possible to import your site from several other blogging sites (like WordPress, Tumblr, ..) using a simple script. See Importing an existing site <#import>. π
π Translations π
It is possible to translate articles. To do so, you need to add a lang meta attribute to your articles/pages and set a DEFAULT_LANG setting (which is English [en] by default). With those settings in place, only articles with the default language will be listed, and each article will be accompanied by a list of available translations for that article.
Note: This core Pelican functionality does not create sub-sites (e.g.example.com/de) with translated templates for each language. For such advanced functionality thei18n_subsitesplugin (https://github.com/getpelican/pelican-plugins/tree/master/i18n_subsites) can be used. π
By default, Pelican uses the article's URL "slug" to determine if two or more articles are translations of one another. (This can be changed with the ARTICLE_TRANSLATION_ID setting.) The slug can be set manually in the file's metadata; if not set explicitly, Pelican will auto-generate the slug from the title of the article.
Here is an example of two articles, one in English and the other in French.
The English article:
Foobar is not dead
##################
:slug: foobar-is-not-dead
:lang: en
That's true, foobar is still alive!
And the French version:
Foobar n'est pas mort !
#######################
:slug: foobar-is-not-dead
:lang: fr
Oui oui, foobar est toujours vivant ! π
Okay but real talk: post content quality notwithstanding, you can see that the only item in common between the two articles is the slug, which is functioning here as an identifier. And if you'd rather not explicitly define the slug this way, you must then instead ensure that the translated article titles are identical, since the slug will be auto-generated from the article title. Slay, that's the rule π
And if you do not want the original version of one specific article to be detected by the DEFAULT_LANG setting, use the translation metadata to specify which posts are translations:
Foobar is not dead
##################
:slug: foobar-is-not-dead
:lang: en
:translation: true
That's true, foobar is still alive!
β¨ Syntax highlighting β¨
Pelican can provide colorized syntax highlighting for your code blocks, and honestly? It's giving main character energy π. To do so, you must use the following conventions inside your content files.
For reStructuredText, use the code-block directive to specify the type of code to be highlighted (in these examples, we'll use python):
.. code-block:: python
print("Pelican is a static site generator.")
For Markdown, which utilizes the CodeHilite extension to provide syntax highlighting, include the language identifier just above the code block, indenting both the identifier and the code:
There are two ways to specify the identifier:
:::python
print("The triple-colon syntax will *not* show line numbers.")
To display line numbers, use a path-less shebang instead of colons:
#!python
print("The path-less shebang syntax *will* show line numbers.")
The specified identifier (e.g. python, ruby) should be one that appears on the list of available lexers, iykyk π
When using reStructuredText the following options are available in the code-block directive:
anchorlinenosβ valid values: N/A β if present, wrap line numbers in<a>tags.classprefixβ valid values: string β string to prepend to token class names.hl_linesβ valid values: numbers β list of lines to be highlighted, where line numbers to highlight are separated by a space. This is similar toemphasize-linesin Sphinx, but it does not support a range of line numbers separated by a hyphen, or comma-separated line numbers.lineanchorsβ valid values: string β wrap each line in an anchor using this string and-linenumber.linenosβ valid values: string β if present or set to"table", output line numbers in a table; if set to"inline", output them inline."none"means do not output the line numbers for this table.linenospecialβ valid values: number β if set, every *n*th line will be given the'special'CSS class.linenostartβ valid values: number β line number for the first line.linenostepβ valid values: number β print every *n*th line number.lineseparatorβ valid values: string β string to print between lines of code,'n'by default.linespansβ valid values: string β wrap each line in a span using this and-linenumber.nobackgroundβ valid values: N/A β if set, do not output background color for the wrapping element.nowrapβ valid values: N/A β if set, do not wrap the tokens at all.tagsfileβ valid values: string βctagsfile to use for name definitions.tagurlformatβ valid values: string β format for the ctag links.
Heads up bestie π β depending on the version, your Pygments module might not have all of these options available. Refer to the HtmlFormatter section of the Pygments documentation for more details on each of the options.
For example, the following code block enables line numbers, starting at 153, and prefixes the Pygments CSS classes with pgcss to make the names more unique and avoid possible CSS conflicts:
.. code-block:: identifier
:classprefix: pgcss
:linenos: table
:linenostart: 153
<indented code block goes here>
It is also possible to specify the PYGMENTS_RST_OPTIONS variable in your Pelican settings file to include options that will be automatically applied to every code block π«Ά
For example, if you want to have line numbers displayed for every code block and a CSS prefix, you would set this variable to:
PYGMENTS_RST_OPTIONS = {'classprefix': 'pgcss', 'linenos': 'table'}
If specified, settings for individual code blocks will override the defaults in your settings file. Periodt β¨
π¦ Publishing drafts π¦
If you want to publish an article or a page as a draft (for friends to review before publishing, for example), you can add a Status: draft attribute to its metadata. That article will then be output to the drafts folder and not listed on the index page nor on any category or tag page. Sneaky little draft era π
If your articles should be automatically published as a draft (to not accidentally publish an article before it is finished), include the status in the DEFAULT_METADATA:
DEFAULT_METADATA = {
'status': 'draft',
}
To publish a post when the default status is draft, update the post's metadata to include Status: published. Boom, shipped π₯
π«£ Hidden Posts
Okay so pages aren't the only ones that can hide β posts can ghost the timeline too, using the Status: hidden attribute. π
Hidden posts still get output to ARTICLE_SAVE_AS like a normal post (no cap, they're really there), but by default they're not included in tag, category, or author indexes, and they're not in the main article feed either. So basically it's giving "unlisted" post energy β published, just not advertised. π
βοΈ Skip Posts
Posts marked with skip status? Those are ignored entirely, bestie. Like, full on left-on-read. They are not processed, they are not output to the ARTICLE_SAVE_AS path, and (same vibe as hidden) they don't show up in indexes or feeds. Gone. Deleted. Not in the group chat. π
π Publish your site
ποΈ Site generation
So once Pelican is installed and you've got some content (Markdown, reST, whatever your heart desires β¨), you convert it to HTML with the pelican command β just point it at your content path, and optionally the path to your settings file:
pelican /path/to/your/content/ [-s path/to/your/settings.py]
That command generates your site and drops it in the output/ folder, using the default theme so you get a cute simple site right away. Heads up though β the default theme is very simple HTML with zero styling, and it's literally provided so folks can use it as a starting point for building their own themes. It's the placeholder, not the final look. π¦
And you don't have to keep re-running it manually every time you tweak something (iykyk, that gets old fast π). Tell Pelican to watch for your modifications by running the pelican command with the -r or --autoreload option. On non-Windows environments you can even stack that with the -l or --listen option so it auto-regenerates and serves the output at <http://localhost:8000> at the same time:
pelican --autoreload --listen
Pelican's got other command-line switches too β go peek at the help to see every option available to you:
pelican --help
π Viewing the generated files
The files Pelican generates are static files, which is the best news ever β you don't need anything special to view them. You can literally just open the generated HTML files straight in your browser:
firefox output/index.html
Thing is, that method might have trouble locating your CSS and other linked assets (classic π), so running Pelican's simple built-in web server usually gives you a way more reliable previewing experience:
pelican --listen
Once the web server is up, preview your site at <http://localhost:8000/> and go admire your work. π
π’ Deployment
So you've generated your site, previewed it in your local dev environment, and now you're ready to send it to production. Before you do, you might want to re-generate with any production-specific settings (analytics, feeds, that kind of thing π ) that you've defined:
pelican content -s publishconf.py
And if you want your publish config to build on top of your pelicanconf.py, just import those settings by including this line in your publishconf.py:
from pelicanconf import *
Fun fact: if you generated a publishconf.py using pelican-quickstart, this line is already in there by default. Slay. β¨
The actual deploying steps depend entirely on where your site's being hosted β no universal answer, sorry bestie. But if you've got SSH access to a server running Nginx or Apache, you might use rsync to send your site files over:
rsync -avc --delete output/ host.example.com:/var/www/your-site/
There are so many other deployment options, and some of them can even be configured when you first set up your site via the pelican-quickstart command. For the full rundown on publishing via GitHub Pages, check the Tips page. π«Ά
π€ Automation
The pelican command is the canonical way to generate your site, but automation tools can streamline the whole generation-and-publication flow. One of the questions in the pelican-quickstart process asks whether you want to automate site generation and publication. If you said "yes" to that one, a tasks.py and a Makefile get generated in the root of your project. π
These files come pre-populated with info gleaned from your other answers during pelican-quickstart, but they're meant as a starting point β customize them to fit your particular needs and usage patterns. And if you find one or both of these automation tools to be of limited utility, honestly, just delete them. Deleting them at any time won't affect usage of the canonical pelican command. β¨
Here are the automation tools that "wrap" the pelican command and can simplify generating, previewing, and uploading your site:
β¨ Invoke
The advantage of Invoke <https://www.pyinvoke.org/> is that it's written in Python, so it can be used across a wide range of environments. The downside? It has to be installed separately. π¦ Install it with:
python -m pip install invoke
(prefix with sudo if your environment requires it!)
Take a sec to open that tasks.py file generated in your project root. You'll see a bunch of commands, and any one of them can be renamed, removed, and/or customized to your liking. With the out-of-the-box config, generate your site via:
invoke build
Prefer Pelican to auto-regenerate every time a change is detected (super handy when testing locally)? Use this one instead:
invoke regenerate
To serve the generated site so you can preview it in your browser at <http://localhost:8000/>:
invoke serve
And to serve it with automatic browser reloading every time a change is detected β first run python -m pip install livereload, then use:
invoke livereload
Oh and if you answered "yes" during pelican-quickstart when asked whether you want to upload your site via SSH, you can publish via rsync over SSH with:
invoke publish
These are just a few of the commands available by default, so go explore tasks.py and see what else is in there. More importantly: don't hesitate to customize tasks.py to suit your specific needs and preferences. It's your file. π
π§΅ Make
A Makefile is also automatically created for you when you say "yes" to the relevant question during pelican-quickstart. The advantage here is that the make command is built into most POSIX systems, so you don't need to install anything else to use it. The downside? Non-POSIX systems (looking at you, Windows π) don't include make, and installing it on those systems can be a non-trivial task. π
If you want to use make to generate your site with the settings in pelicanconf.py, run:
make html
For production β using the settings in publishconf.py β run:
make publish
Want Pelican to auto-regenerate every time a change is detected (handy for local testing)? Use:
make regenerate
To serve the generated site so it's previewable in your browser at <http://localhost:8000/>:
make serve
Normally you'd need to run make regenerate and make serve in two separate terminal sessions, but you can run both at once with:
make devserver
That command simultaneously runs Pelican in regeneration mode and serves the output at <http://localhost:8000>. Multitasking icon. π
When you're ready to publish, upload it via the method(s) you chose during the pelican-quickstart questionnaire. In this example we'll use rsync over ssh:
make rsync_upload
That's it! Your site should now be live. ππ
Heads up: the defaultMakefileanddevserver.shscripts use thepythonandpelicanexecutables to complete their tasks. If you want different executables β likepython3, bestie β you can set thePYandPELICANenvironment variables, respectively, to override the default executable names. πΈ
βοΈ Settings
Pelican is configurable thanks to a settings file you can pass right on the command line:
pelican content -s path/to/your/pelicanconf.py
And if you used pelican-quickstart, your primary settings file will be named pelicanconf.py by default. π
You can also specify settings via the -e / --extra-settings option flags. These override default settings as well as anything defined within the settings file. Just know the values must follow JSON notation:
pelican content -e SITENAME='"A site"' READERS='{"html": null}' CACHE_CONTENT=true
Environment variables work here too, but they must be escaped appropriately:
pelican content -e API_KEY=''\"$API_KEY\"''
Note: when experimenting with different settings (especially the metadata ones), caching may interfere and your changes may not be visible. π± In such cases, disable caching withLOAD_CONTENT_CACHE = Falseor use the--ignore-cachecommand-line switch.
Settings are configured in the form of a Python module (a file). There's an example settings file <https://raw.githubusercontent.com/getpelican/pelican/main/samples/pelican.conf.py> available for reference. π¦
To see a list of current settings in your environment β including both default and any customized values β run this command (you can append one or more specific setting names as arguments to see values for just those settings):
pelican --print-settings
Okay this next bit is important, so pay attention bestie: all setting identifiers must be set in all-caps, otherwise they won't be processed. Setting values that are numbers (5, 20, etc.), booleans (True, False, None, etc.), dictionaries, or tuples should not be enclosed in quotation marks. All other values (i.e., strings) must be enclosed in quotation marks. π Don't mix this up.
Unless otherwise specified, settings that refer to paths can be either absolute or relative to the configuration file. And the settings you define in the config file get passed to the templates β which means you can use your settings to add site-wide content. Iconic. β¨
Here's a list of settings for Pelican:
π§Έ Basic settings
USE_FOLDER_AS_CATEGORYβ when you don't specify a category in your post metadata, set this toTrue, organize your articles in subfolders, and the subfolder becomes the category of your post. If it'sFalse,DEFAULT_CATEGORYis used as the fallback instead. Default isTrue. πDEFAULT_CATEGORYβ the default category to fall back on. Default is"misc". πDISPLAY_PAGES_ON_MENUβ whether to display pages on the menu of the template. Templates may or may not honor this setting (rude, but okay π). Default isTrue.DISPLAY_CATEGORIES_ON_MENUβ whether to display categories on the menu of the template. Templates may or not honor this setting. Default isTrue.DOCUTILS_SETTINGSβ extra configuration settings for the docutils publisher (applicable only to reStructuredText βοΈ). See the Docutils Configuration settings at <http://docutils.sourceforge.net/docs/user/config.html> for more details. Default is{}with no extra configuration settings.
DELETE_OUTPUT_DIRECTORY
Nukes the output directory β like, the whole entire thing, every file in it β before generating new files. Genuinely useful for stopping crusty old files from just vibing in your output forever π. But bestie, be so for real: this is a destructive setting, so handle it with extreme care.
Default is False. Do not fumble this one.
OUTPUT_RETENTION
A list of filenames that should be retained and not deleted from the output directory. Classic use case? Preserving version control data, iykyk β¨.
Example:
OUTPUT_RETENTION = [".hg", ".git", ".bzr"]
Default is [].
JINJA_ENVIRONMENT
A dictionary of custom Jinja2 environment variables you want to use β and it also includes a list of extensions you might want to include. Peep the Jinja Environment documentation at https://jinja.palletsprojects.com/en/latest/api/#jinja2.Environment π.
Default is {"extensions": [], "trim_blocks": True, "lstrip_blocks": True}.
JINJA_FILTERS
A dictionary of custom Jinja2 filters you want to use. The dictionary should map the filtername to the filter function π.
Example:
import sys
sys.path.append("to/your/path")
from custom_filter import urlencode_filter
JINJA_FILTERS = {"urlencode": urlencode_filter}
See the Jinja custom filters documentation: https://jinja.palletsprojects.com/en/latest/api/#custom-filters.
Default is {}.
JINJA_GLOBALS
A dictionary of custom objects to map into the Jinja2 global environment namespace. The dictionary should map the global name to the global variable/function. See the Jinja global namespace documentation: https://jinja.palletsprojects.com/en/latest/api/#the-global-namespace πΈ.
Default is {}.
JINJA_TESTS
A dictionary of custom Jinja2 tests you want to use. The dictionary should map test names to test functions. See the Jinja custom tests documentation: https://jinja.palletsprojects.com/en/latest/api/#custom-tests π¦.
Default is {}.
LOG_FILTER
A list of tuples containing the logging level (up to warning) and the message to be ignored π.
Example:
LOG_FILTER = [(logging.WARN, "TAG_SAVE_AS is set to False")]
Default is [].
READERS
A dictionary of file extensions / Reader classes for Pelican to process or ignore π.
So like, to avoid processing .html files, set:
READERS = {"html": None}
And to add a custom reader for the foo extension, set:
READERS = {"foo": FooReader}
Default is {}.
IGNORE_FILES
A list of Unix glob patterns. Files and directories matching any of these patterns β or any of the commonly hidden files and directories set by watchfiles.DefaultFilter β will be ignored by the processor π. For example, the default ["**/.*"] will ignore "hidden" files and directories, and ["__pycache__"] would ignore Python 3's bytecode caches.
For the full list of the commonly hidden files set by watchfiles.DefaultFilter, please refer to the watchfiles documentation: https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_dirs.
Default is ["**/.*"].
MARKDOWN
Extra configuration settings for the Markdown processor. Refer to the Python Markdown documentation's Options section β https://python-markdown.github.io/reference/#markdown β for the complete list of supported options. The extensions option will be automatically computed from the extension_configs option β¨.
Default is:
MARKDOWN = {
"extension_configs": {
"markdown.extensions.codehilite": {"css_class": "highlight"},
"markdown.extensions.extra": {},
"markdown.extensions.meta": {},
},
"output_format": "html5",
}
Note: the dictionary defined in your settings file will replace this default one. Like, fully replace it, no merging, just gone π .
OUTPUT_PATH
Where to output the generated files. This should correspond to your web server's virtual host root directory π .
Default is "output".
PATH
Path to the content directory to be processed by Pelican. If it's undefined, and the content path isn't specified via an argument to the pelican command, Pelican will default to "." β the current working directory, bestie.
PAGE_PATHS
A list of directories and files to look at for pages, relative to PATH π.
Default is ["pages"].
PAGE_EXCLUDES
A list of directories to exclude when looking for pages β in addition to ARTICLE_PATHS.
Default is [].
ARTICLE_PATHS
A list of directories and files to look at for articles, relative to PATH π.
Default is [""].
ARTICLE_EXCLUDES
A list of directories to exclude when looking for articles β in addition to PAGE_PATHS.
Default is [].
OUTPUT_SOURCES
Set to True if you want to copy the articles and pages in their original format (e.g. Markdown or reStructuredText) to the specified OUTPUT_PATH π«Ά.
Default is False.
OUTPUT_SOURCES_EXTENSION
Controls the extension that will be used by the SourcesGenerator. Defaults to .text. If it's not a valid string, the default value will be used π.
Default is ".text".
PLUGINS
The list of plugins to load. See Plugins.
Default is None.
PLUGIN_PATHS
A list of directories where to look for plugins. See Plugins.
Default is [].
SITENAME
Your site's name π.
Default is "A Pelican Blog".
SITEURL
Base URL of your web site. Not defined by default β which is why it's genuinely best to specify your SITEURL. If you don't, feeds will not be generated with properly-formed URLs π. If your site is available via HTTPS, this setting should begin with https:// β otherwise use http://. Then append your domain, with no trailing slash at the end.
Example:
SITEURL = "https://example.com"
Default is "", the blank string.
STATIC_PATHS
A list of directories (relative to PATH) in which to look for static files. Such files will be copied to the output directory without modification πΌοΈ. Articles, pages, and other content source files will normally be skipped, so it's totally safe for a directory to appear both here and in PAGE_PATHS or ARTICLE_PATHS. Pelican's default settings include the "images" directory here.
Default is ["images"].
STATIC_EXCLUDES
A list of directories to exclude when looking for static files.
Default is [].
STATIC_EXCLUDE_SOURCES
If set to False, content source files will not be skipped when copying files found in STATIC_PATHS. This setting exists for backward compatibility with Pelican releases before version 3.5. It has no effect unless STATIC_PATHS contains a directory that's also in ARTICLE_PATHS or PAGE_PATHS. If you're trying to publish your site's source files, consider using the OUTPUT_SOURCES setting instead, fr fr π.
Default is True.
STATIC_CREATE_LINKS
Create links instead of copying files. If the content and output directories are on the same device, then create hard links π. Falls back to symbolic links if the output directory is on a different filesystem. If symlinks are created, don't forget to add the -L or --copy-links option to rsync when uploading your site, bestie!
Default is False.
STATIC_CHECK_IF_MODIFIED
If set to True, and STATIC_CREATE_LINKS is False, compare mtimes of content and output files, and only copy content files that are newer than existing output files β°.
Default is False.
TYPOGRIFY
If set to True, several typographical improvements will be incorporated into the generated HTML via the Typogrify library (https://pypi.org/project/typogrify/), which can be installed via:
python -m pip install typogrify
Default is False.
TYPOGRIFY_IGNORE_TAGS
A list of tags for Typogrify to ignore. By default Typogrify will ignore pre and code tags. This requires that Typogrify version 2.0.4 or later is installed β.
Default is [].
TYPOGRIFY_OMIT_FILTERS
A list of Typogrify filters to skip. Allowed values are: "amp", "smartypants", "caps", "initial_quotes", "widont" π. By default, no filter is omitted (in other words, all filters get applied). This setting requires that Typogrify version 2.1.0 or later is installed.
Default is [].
TYPOGRIFY_DASHES
This setting controls how Typogrify sets up the Smartypants filter to interpret multiple dash/hyphen/minus characters. A single ASCII dash character (-) is always rendered as a hyphen π
.
- The
defaultsetting does not handle en-dashes and converts double-hyphens into em-dashes. - The
oldschoolsetting renders both en-dashes and em-dashes when it sees two (--) and three (---) hyphen characters, respectively. - The
oldschool_invertedsetting turns two hyphens into an em-dash and three hyphens into an en-dash.
Default is "default".
SUMMARY_MAX_LENGTH
When creating a short summary of an article, this will be the default length (measured in words) of the text created π. This only applies if your content doesn't otherwise specify a summary. Setting it to None will cause the summary to be a copy of the original content.
Default is 50.
SUMMARY_MAX_PARAGRAPHS
When creating a short summary of an article, this will be the number of paragraphs to use as the summary π. This only applies if your content doesn't otherwise specify a summary. Setting it to None will cause the summary to use the whole text (up to SUMMARY_MAX_LENGTH) instead of just the first N paragraphs.
Default is None.
SUMMARY_END_SUFFIX
When creating a short summary of an article and the result was truncated to match the required word length, this will be used as the truncation suffix βοΈ.
Default is "β¦".
WITH_FUTURE_DATES
If disabled, content with dates in the future will get a default status of draft. See Reading Only Modified Content for caveats π.
Default is True.
INTRASITE_LINK_REGEXβ the regex Pelican uses to parse internal links π the default syntax for linking to internal files, tags, etc. is to wrap the identifier (say,filename) in{}or||. Whatever sits between{and}lands in thewhatcapturing group. For the full tea, see Linking to internal content <#ref-linking-to-internal-content>. Default is"[{|](?P<what>.*?)[|}]".PYGMENTS_RST_OPTIONSβ a list of default Pygments settings for your reStructuredText code blocks β¨ peep Syntax highlighting <#internal-pygments-options> for the list of supported options. Default is{}.CACHE_CONTENTβ ifTrue, saves content in caches πΎ see Reading Only Modified Content for the details on caching. Default isFalse.CONTENT_CACHING_LAYERβ set it to"reader"and it saves only the raw content and metadata that readers return; set it to"generator"and it saves processed content objects. Default is"reader".CACHE_PATHβ the directory where cache files get stored ποΈ default is"cache".GZIP_CACHEβ ifTrue, gzip is used to (de)compress the cache files. Default isTrue.CHECK_MODIFIED_METHODβ controls how files get checked for modifications π- set it to
"mtime"and the modification time of the file is checked - set it to the name of a function provided by the
hashlibmodule, e.g."md5", and the file hash is checked
- set it to
Default is "mtime".
LOAD_CONTENT_CACHEβ ifTrue, loads unmodified content from caches. Default isFalse.FORMATTED_FIELDSβ a list of metadata fields containing reST/Markdown content that should be parsed and translated to HTML πΈ default is["summary"].PORTβ the TCP port to serve content from the output folder via HTTP when pelican is run with--listenπ₯οΈ default is8000.BINDβ the IP to which to bind the HTTP server. Default is"127.0.0.1".
π URL settings π
okay so the first thing to understand is that there are currently two supported methods for URL formation: relative and absolute π
relative URLs are useful when you're testing locally, and absolute URLs are reliable and most useful when 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 type of setup, use the pelican-quickstart script as described in the Installation <> section β it'll produce two separate configuration files for local development and publishing, respectively β¨
you can customize the URLs and locations where files will be saved. the *_URL and *_SAVE_AS variables use Python's format strings. these variables let you place your articles in a location such as {slug}/index.html and link to them as {slug} for clean URLs (see the example below). these settings give you the flexibility to place your articles and pages anywhere you want π«Ά
Note: if a*_SAVE_ASsetting contains a parent directory that doesn't match the parent directory inside the corresponding*_URLsetting, this may cause Pelican to generate unexpected URLs in a few cases, such as when using the{attach}syntax π
if you don't want that flexibility and instead prefer that your generated output paths mirror your source content's filesystem path hierarchy, try these settings:
PATH_METADATA = r"(?P<path_no_ext>.*)\..*"
ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = "{path_no_ext}.html"
otherwise, you can use a variety of file metadata attributes within URL-related settings πΈ
slugdatelangauthorcategory
Example usage:
ARTICLE_URL = "posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/"
ARTICLE_SAVE_AS = "posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/index.html"
PAGE_URL = "pages/{slug}/"
PAGE_SAVE_AS = "pages/{slug}/index.html"
this would save your articles into something like /posts/2011/Aug/07/sample-post/index.html, save your pages into /pages/about/index.html, and render them available at URLs of /posts/2011/Aug/07/sample-post/ and /pages/about/, respectively π₯
Note: if you specify a datetime directive, it will be substituted using the input files' date metadata attribute. if the date isn't specified for a particular file, Pelican will rely on the file's mtime timestamp. check the Python datetime documentation <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior> for more info π
RELATIVE_URLSβ defines whether Pelican should use document-relative URLs or not. only set this toTruewhen developing/testing, and only if you fully understand the effect it can have on links/feeds π default isFalse.ARTICLE_URLβ the URL to refer to an article. Default is"{slug}.html".ARTICLE_SAVE_ASβ the place where we will save an article. Default is"{slug}.html".ARTICLE_LANG_URLβ the URL to refer to an article which doesn't use the default language. Default is"{slug}-{lang}.html".ARTICLE_LANG_SAVE_ASβ the place where we will save an article which doesn't use the default language. Default is"{slug}-{lang}.html".DRAFT_URLβ the URL to refer to an article draft. Default is"drafts/{slug}.html".DRAFT_SAVE_ASβ the place where we will save an article draft. Default is"drafts/{slug}.html".DRAFT_LANG_URLβ the URL to refer to an article draft which doesn't use the default language. Default is"drafts/{slug}-{lang}.html".DRAFT_LANG_SAVE_ASβ the place where we will save an article draft which doesn't use the default language. Default is"drafts/{slug}-{lang}.html".PAGE_URLβ the URL we will use to link to a page. Default is"pages/{slug}.html".PAGE_SAVE_ASβ the location we will save the page. β οΈ this value has to be the same asPAGE_URLor you need to use a rewrite in your server config. Default is"pages/{slug}.html".PAGE_LANG_URLβ the URL we will use to link to a page which doesn't use the default language. Default is"pages/{slug}-{lang}.html".PAGE_LANG_SAVE_ASβ the location we will save the page which doesn't use the default language. Default is"pages/{slug}-{lang}.html".DRAFT_PAGE_URLβ the URL used to link to a page draft. Default is"drafts/pages/{slug}.html".DRAFT_PAGE_SAVE_ASβ the actual location a page draft is saved at. Default is"drafts/pages/{slug}.html".DRAFT_PAGE_LANG_URLβ the URL used to link to a page draft which doesn't use the default language. Default is"drafts/pages/{slug}-{lang}.html".DRAFT_PAGE_LANG_SAVE_ASβ the actual location a page draft which doesn't use the default language is saved at. Default is"drafts/pages/{slug}-{lang}.html".AUTHOR_URLβ the URL to use for an author. Default is"author/{slug}.html".AUTHOR_SAVE_ASβ the location to save an author. Default is"author/{slug}.html".CATEGORY_URLβ the URL to use for a category. Default is"category/{slug}.html".CATEGORY_SAVE_ASβ the location to save a category. Default is"category/{slug}.html".TAG_URLβ the URL to use for a tag. Default is"tag/{slug}.html".TAG_SAVE_ASβ the location to save the tag page. Default is"tag/{slug}.html".
Note: if you do not want one or more of the default pages to be created (e.g., you're the only author on your site and thus do not need an Authors page), set the corresponding*_SAVE_ASsetting to""to prevent the relevant page from being generated π
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 enabled if you supply format strings for their respective _SAVE_AS settings. period archives fit intuitively with the hierarchical model of web URLs and can make it easier for readers to navigate through the posts you've written over time β¨
Example usage:
YEAR_ARCHIVE_SAVE_AS = "posts/{date:%Y}/index.html"
YEAR_ARCHIVE_URL = "posts/{date:%Y}/"
MONTH_ARCHIVE_SAVE_AS = "posts/{date:%Y}/{date:%b}/index.html"
MONTH_ARCHIVE_URL = "posts/{date:%Y}/{date:%b}/"
with these settings, Pelican will create an archive of all your posts for the year at (for instance) posts/2011/index.html and an archive of all your posts for the month at posts/2011/Aug/index.html. these can be accessed through the URLs posts/2011/ and posts/2011/Aug/, respectively π
Note: period archives work best when the final path segment is index.html. that way a reader can remove a portion of your URL and automatically arrive at an appropriate archive of posts, without having to specify a page name π
YEAR_ARCHIVE_SAVE_ASβ the location to save per-year archives of your posts. Default is"", i.e. this is disabled by default.YEAR_ARCHIVE_URLβ the URL to use for per-year archives of your posts. you should set this if you enable per-year archives. Default is"", i.e. this is disabled by default.MONTH_ARCHIVE_SAVE_ASβ the location to save per-month archives of your posts. Default is"", i.e. this is disabled by default.MONTH_ARCHIVE_URLβ the URL to use for per-month archives of your posts. you should set this if you enable per-month archives. Default is"", i.e. this is disabled by default.DAY_ARCHIVE_SAVE_ASβ the location to save per-day archives of your posts. Default is"", i.e. this is disabled by default.DAY_ARCHIVE_URLβ the URL to use for per-day archives of your posts. you should set this if you enable per-day archives. Default is"", i.e. this is disabled by default.
DIRECT_TEMPLATES work a bit differently than noted above π only the _SAVE_AS settings are available, but it is available for any direct template.
ARCHIVES_SAVE_ASβ the location to save the article archives page. Default is"archives.html".AUTHORS_SAVE_ASβ the location to save the author list. Default is"authors.html".CATEGORIES_SAVE_ASβ the location to save the category list. Default is"categories.html".TAGS_SAVE_ASβ where the tag list gets saved π·οΈ default is"tags.html".INDEX_SAVE_ASβ where the big ol' list of all your articles goes. default is"index.html"π
URLs for direct template pages are theme-dependent, bestie. Some themes use the corresponding *_URL setting as a string, while others just hard-code them: "archives.html", "authors.html", "categories.html", "tags.html".
SLUGIFY_SOURCEβ tells Pelican where the slug should be auto-generated from β¨ Set it totitleto use the"Title:"metadata tag, orbasenameto use the article's file name when creating the slug. default is"title".SLUGIFY_USE_UNICODEβ lets Unicode characters live in your slugs π¦ SetTrueto keep Unicode characters in auto-generated slugs. Otherwise, Unicode characters get replaced with ASCII equivalents. default isFalse.SLUGIFY_PRESERVE_CASEβ keeps the uppercase vibes π SetTrueto keep uppercase characters fromSLUGIFY_SOURCEas-is. default isFalse.SLUG_REGEX_SUBSTITUTIONSβ the regex substitutions to make when generating slugs of articles and pages. Specified as a list of pairs of (from,to) which are applied in order, ignoring case. The default substitutions have the effect of removing non-alphanumeric characters and converting internal whitespace to dashes. Apart from these substitutions, slugs are always converted to lowercase ascii characters and leading and trailing whitespace is stripped. Lowkey useful for backward compatibility with existing URLs. The default is:
[
(r"[^\w\s-]", ""), # remove non-alphabetical/whitespace/"-" chars
(r"(?u)\A\s*", ""), # strip leading whitespace
(r"(?u)\s*\Z", ""), # strip trailing whitespace
(r"[-\s]+", "-"), # reduce multiple whitespace or "-" to single "-"
]
AUTHOR_REGEX_SUBSTITUTIONSβ regex substitutions for author slugs. default isSLUG_REGEX_SUBSTITUTIONS.CATEGORY_REGEX_SUBSTITUTIONSβ regex substitutions for category slugs. default isSLUG_REGEX_SUBSTITUTIONS.TAG_REGEX_SUBSTITUTIONSβ regex substitutions for tag slugs. default isSLUG_REGEX_SUBSTITUTIONS.
π°οΈ Time and Date π°οΈ
TIMEZONEβ the timezone used in the date information, to generate Atom and RSS feeds π
If no timezone is defined, UTC is assumed. This means that the generated Atom and RSS feeds will contain incorrect date information if your locale is not UTC π
Pelican issues a warning in case this setting is not defined, as it was not mandatory in previous versions.
Have a look at the wikipedia page https://en.wikipedia.org/wiki/List_of_tz_database_time_zones to get a list of valid timezone values β¨
DEFAULT_DATEβ the default date you want to use. If"fs", Pelican will use the file system timestamp information (mtime) if it can't get date information from the metadata. If given any other string, it will be parsed by the same method as article metadata. If set to a tuple object, the default datetime object will instead be generated by passing the tuple to thedatetime.datetimeconstructor. default isNone.DEFAULT_DATE_FORMATβ the default date format you want to use. default is"%a %d %B %Y", e.g."Mon 06 April 2026"πDATE_FORMATSβ if you manage multiple languages, you can set the date formatting here π
If no DATE_FORMATS are set, Pelican will fall back to DEFAULT_DATE_FORMAT. If you need to maintain multiple languages with different date formats, you can set the DATE_FORMATS dictionary using the language name (lang metadata in your post content) as the key.
In addition to the standard C89 strftime format codes that are listed in Python datetime documentation (https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior), you can use the - character between % and the format character to remove any leading zeros. For example, %d/%m/%Y will output 01/01/2014 whereas %-d/%-m/%Y will result in 1/1/2014 π
DATE_FORMATS = {
"en": "%a, %d %b %Y",
"jp": "%Y-%m-%d(%a)",
}
It is also possible to set different locale settings for each language by using a (locale, format) tuple as a dictionary value which will override the LOCALE setting:
# On Unix/Linux
DATE_FORMATS = {
"en": ("en_US", "%a, %d %b %Y"),
"jp": ("ja_JP", "%Y-%m-%d(%a)"),
}
# On Windows
DATE_FORMATS = {
"en": ("usa", "%a, %d %b %Y"),
"jp": ("jpn", "%Y-%m-%d(%a)"),
}
default is {}.
LOCALEβ change the locale π A list of locales can be provided here or a single string representing one locale. When providing a list, all the locales will be tried until one works.
You can set locale to further control date format:
LOCALE = [
"usa", "jpn", # On Windows
"en_US", "ja_JP" # On Unix/Linux
]
For a list of available locales refer to locales on Windows (https://www.microsoft.com/en-us/download/details.aspx?id=55979) or on Unix/Linux, use the locale -a command; see manpage locale(1) (https://linux.die.net/man/1/locale) for more information. default is the system locale.
π§ Template pages π§
TEMPLATE_PAGESβ a mapping containing template pages that will be rendered with the blog entries β¨
If you want to generate custom pages besides your blog entries, you can point any Jinja2 template file with a path pointing to the file and the destination path for the generated file.
For instance, if you have a blog with three static pages β a list of books, your resume, and a contact page β you could have:
TEMPLATE_PAGES = {
"src/books.html": "dest/books.html",
"src/resume.html": "dest/resume.html",
"src/contact.html": "dest/contact.html",
}
default is {}.
TEMPLATE_EXTENSIONSβ the extensions to use when looking up template files from template names. default is[".html"].DIRECT_TEMPLATESβ list of templates that are used directly to render content π Typically direct templates are used to generate index pages for collections of content (e.g., category and tag index pages). If the author, category and tag collections are not needed, setDIRECT_TEMPLATES = ["index", "archives"]
DIRECT_TEMPLATES are searched for over paths maintained in THEME_TEMPLATES_OVERRIDES.
default is ["index", "tags", "categories", "authors", "archives"].
π·οΈ Metadata π·οΈ
AUTHORβ default author (usually your name). default isNone, which removes the byline πDEFAULT_METADATAβ the default metadata you want to use for all articles and pages. default is{}.FILENAME_METADATAβ the regexp that will be used to extract any metadata from the filename. All named groups that are matched will be set in the metadata object π default value isr"(?P<date>\d{4}-\d{2}-\d{2}).*"and will only extract the date from the filename.
For example, if your source file were titled 2026-04-30_blog-article.md, you could extract both the date and the slug:
FILENAME_METADATA = r"(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)"
giving you a date of April 30, 2026 and a slug of blog-article π
See also SLUGIFY_SOURCE. default is r"(?P<date>\d{4}-\d{2}-\d{2}).*", i.e. it assumed your filenames start with an ISO-style date, e.g. 2026-04-30.
See also, FILENAME_METADATA.
PATH_METADATAβ likeFILENAME_METADATA, but parsed from a page's full path relative to the content source directory, include the source filename. default value is"".
For example, if your source files were stored in folders by year and then my month, with the filename being the day of the month, (e.g. 2026/04/30.rst) you could extract that with:
PATH_METADATA = r"(?P<date>\d{4}/\d{2}/\d{2}).*"
(The above works on Windows as well.)
See also FILENAME_METADATA.
EXTRA_PATH_METADATAβ extra metadata dictionaries keyed by relative path. Relative paths require correct OS-specific directory separators (i.e./in UNIX and\in Windows) unlike some other Pelican file settings. Paths to a directory apply to all files under it. The most-specific path wins conflicts π
Not all metadata needs to be embedded in source file itself (that's the internal-metadata thing). For example, blog posts are often named following a YYYY-MM-DD-SLUG.rst pattern, or nested into YYYY/MM/DD-SLUG directories. To extract metadata from the filename or path, set FILENAME_METADATA or PATH_METADATA to regular expressions that use Python's group name notation (https://docs.python.org/3/library/re.html#regular-expression-syntax) (?P<name>β¦). If you want to attach additional metadata but don't want to encode it in the path, you can set EXTRA_PATH_METADATA:
EXTRA_PATH_METADATA = {
"relative/path/to/file-1": {
"key-1a": "value-1a",
"key-1b": "value-1b",
},
"relative/path/to/file-2": {
"key-2": "value-2",
},
}
This can be a convenient way to shift the output location of a particular file:
# Take advantage of the following defaults:
# STATIC_SAVE_AS = "{path}"
# STATIC_URL = "{path}"
STATIC_PATHS = [
"static/robots.txt",
]
EXTRA_PATH_METADATA = {
"static/robots.txt": {"path": "robots.txt"},
}
default is {}.
π‘ Feed settings π‘
By default, Pelican uses Atom feeds. However, it is also possible to use RSS feeds if you prefer π«Ά
Pelican generates category feeds as well as feeds for all your articles. It does not generate feeds for tags by default, but bestie, you absolutely can β just use the TAG_FEED_ATOM and TAG_FEED_RSS settings:
FEED_DOMAINβ the domain prepended to feed URLs. Since feed URLs should always be absolute, it is highly recommended to define this (e.g.,https://feeds.example.com). The default isSITEURL. π«ΆFEED_ATOMβ the location to save the Atom feed. The default isNone, for no Atom feed.FEED_ATOM_URLβ relative URL of the Atom feed. If not set,FEED_ATOMis used both for save location and URL. The default isNone.FEED_RSSβ the location to save the RSS feed. The default isNone, for no RSS feed.FEED_RSS_URLβ relative URL of the RSS feed. If not set,FEED_RSSis used both for save location and URL. The default isNone.FEED_ALL_ATOMβ the location to save the all-posts Atom feed: this feed will contain all posts regardless of their language. The default is"feeds/all.atom.xml".FEED_ALL_ATOM_URLβ relative URL of the all-posts Atom feed. If not set,FEED_ALL_ATOMis used both for save location and URL. The default isNone.FEED_ALL_RSSβ the location to save the all-posts RSS feed: this feed will contain all posts regardless of their language. The default isNone, for no all-posts RSS feed.FEED_ALL_RSS_URLβ relative URL of the all-posts RSS feed. If not set,FEED_ALL_RSSis used both for save location and URL. The default isNone.CATEGORY_FEED_ATOMβ the location to save the category Atom feeds. [2] The default is"feeds/{slug}.atom.xml".CATEGORY_FEED_ATOM_URLβ relative URL of the category Atom feeds, including the{slug}placeholder. [2] If not set,CATEGORY_FEED_ATOMis used both for save location and URL. The default isNone.CATEGORY_FEED_RSSβ the location to save the category RSS feeds, including the{slug}placeholder. [2] The default isNone, for no RSS feed.CATEGORY_FEED_RSS_URLβ relative URL of the category RSS feeds, including the{slug}placeholder. [2] If not set,CATEGORY_FEED_RSSis used both for save location and URL. The default isNone.AUTHOR_FEED_ATOMβ the location to save the author Atom feeds. [2] The default is"feeds/{slug}.atom.xml".AUTHOR_FEED_ATOM_URLβ relative URL of the author Atom feeds, including the{slug}placeholder. [2] If not set,AUTHOR_FEED_ATOMis used both for save location and URL. The default isNone(not set).AUTHOR_FEED_RSSβ the location to save the author RSS feeds. [2] The default is"feeds/{slug}.rss.xml".AUTHOR_FEED_RSS_URLβ relative URL of the author RSS feeds, including the{slug}placeholder. [2] If not set,AUTHOR_FEED_RSSis used both for save location and URL. The default isNone.TAG_FEED_ATOMβ the location to save the tag Atom feed, including the{slug}placeholder. [2] The default isNone, for no tag feed.TAG_FEED_ATOM_URLβ relative URL of the tag Atom feed, including the{slug}placeholder. [2] The default isNone.TAG_FEED_RSSβ relative URL to output the tag RSS feed, including the{slug}placeholder. If not set,TAG_FEED_RSSis used both for save location and URL. The default isNone, for no tag feed.FEED_MAX_ITEMSβ maximum number of items allowed in a feed. Setting toNonewill cause the feed to contain every article. The default is100.RSS_FEED_SUMMARY_ONLYβ only include item summaries in thedescriptiontag of RSS feeds. If set toFalse, the full content will be included instead. This setting doesn't affect Atom feeds, only RSS ones. The default isTrue.FEED_APPEND_REFβ if set toTrue,?ref=feedwill be appended to links in generated feeds for the purpose of referrer tracking. The default isFalse.
If you don't want to generate some or any of these feeds, just set the above variables to None. Girl math: None = no feed, no problem. π
[2] {slug} is replaced by name of the category / author / tag.
π Pagination π
So the default behaviour of Pelican is to list all the article titles along with a short description on the index page. Works great for small-to-medium sites, but bestieβ¦ sites with a large quantity of articles will probably benefit from paginating this list. Like, your index page shouldn't be a whole novel. π
You can use the following settings to configure the pagination:
DEFAULT_ORPHANSβ the minimum number of articles allowed on the last page. Use this when you don't want the last page to only contain a handful of articles. The default is0.DEFAULT_PAGINATIONβ the maximum number of articles to include on a page, not including orphans.Falseto disable pagination. The default isFalse.PAGINATED_TEMPLATESβ the templates to use pagination with, and the number of articles to include on a page. If this value isNone, it defaults toDEFAULT_PAGINATION. The default is{"index": None, "tag": None, "category": None, "author": None}.PAGINATION_PATTERNSβ a set of patterns that are used to determine advanced pagination output. The default is:
(
(1, "{name}{extension}", "{name}{extension}"),
(2, "{name}{number}{extension}", "{name}{number}{extension}""),
)
β¨ Using Pagination Patterns β¨
By default, pages subsequent to .../foo.html are created as .../foo2.html, etc. The PAGINATION_PATTERNS setting can be used to change this. It takes a sequence of triples, where each triple consists of:
(minimum_page, page_url, page_save_as,)
For page_url and page_save_as, you may use a number of variables. {url} and {save_as} correspond respectively to the *_URL and *_SAVE_AS values of the corresponding page type (e.g. ARTICLE_SAVE_AS). If {save_as} == foo/bar.html, then {name} == foo/bar and {extension} == .html. {base_name} equals {name} except that it strips trailing /index if present. {number} equals the page number. π¦
For example, if you want to leave the first page unchanged, but place subsequent pages at .../page/2/ etc, you could set PAGINATION_PATTERNS as follows:
PAGINATION_PATTERNS = (
(1, "{url}", "{save_as}"),
(2, "{base_name}/page/{number}/", "{base_name}/page/{number}/index.html"),
)
If you want a pattern to apply to the last page in the list, use -1 as the minimum_page value:
(-1, "{base_name}/last/", "{base_name}/last/index.html"),
Iconic. Chef's kiss. π€
π Translations π
Pelican offers a way to translate articles. See the Content section for more information. (Yes, the whole content section β go read it, iykyk.)
DEFAULT_LANGβ the default language to use. The default is"en".ARTICLE_TRANSLATION_IDβ the metadata attribute(s) used to identify which articles are translations of one another. May be a string or a collection of strings. Set toNoneorFalseto disable the identification of translations. The default is"slug".PAGE_TRANSLATION_IDβ the metadata attribute(s) used to identify which pages are translations of one another. May be a string or a collection of strings. Set toNoneorFalseto disable the identification of translations. The default is"slug".TRANSLATION_FEED_ATOMβ the location to save the Atom feed for translations. [3] The default is"feeds/all-{lang}.atom.xml".TRANSLATION_FEED_ATOM_URLβ relative URL of the Atom feed for translations, including the{lang}placeholder. [3] If not set,TRANSLATION_FEED_ATOMis used both for save location and URL. The default isNone.TRANSLATION_FEED_RSSβ where to put the RSS feed for translations. The default isNone, meaning no RSS feed.TRANSLATION_FEED_RSS_URLβ relative URL of the RSS feed for translations, including the{lang}placeholder. [3] If not set,TRANSLATION_FEED_RSSis used both for save location and URL. The default isNone.
[3] {lang} is the language code. π
π Ordering content π
NEWEST_FIRST_ARCHIVESβ order archives by newest first by date. (False: orders by date with older articles first.) The default isTrue.REVERSE_CATEGORY_ORDERβ reverse the category order. (True: lists by reverse alphabetical order; default lists alphabetically.) The default isFalse.ARTICLE_ORDER_BYβ defines how the articles (articles_page.object_listin the template) are sorted. Valid options are: metadata as a string (usereversed-prefix to reverse the sort order), special option"basename"which will use the basename of the file (without path), or a custom function to extract the sorting key from articles. Using a value of"date"will sort articles in chronological order, while the default value,"reversed-date", will sort articles by date in reverse order (i.e., newest article comes first). The default is"reversed-date".PAGE_ORDER_BYβ defines how the pages (pagesvariable in the template) are sorted. Options are same asARTICLE_ORDER_BY. The default value,"basename"will sort pages by their basename. The default is"basename".
π Themes π
Creating Pelican themes is addressed in a dedicated section (see Themes). However, here are the settings that are related to themes. Like, the theme girlies get their own lil subsection, slay.
THEMEβ theme to use to produce the output. Can be a relative or absolute path to a theme folder, or the name of a default theme or a theme installed viapelican-themes(see below). The default theme is"notmyidea".THEME_STATIC_DIRβ destination directory in the output path where Pelican will place the files collected fromTHEME_STATIC_PATHS. Default istheme. The default is"theme".THEME_STATIC_PATHSβ static theme paths you want to copy. Default value isstatic, but if your theme has other static paths, you can put them here. If files or directories with the same names are included in the paths defined in this settings, they will be progressively overwritten. The default is["static"].
π§ Heads up bestie: those last-wins overwrites are real β paths listed later progressively overwrite earlier ones with the same names. Not a vibe check you want to fail.
THEME_TEMPLATES_OVERRIDESβ a list of paths you want Jinja2 to go look through before it searches the theme'stemplates/directory π this is the slay way to override individual theme template files without having to fork a whole entire theme, ok? Jinja2 searches in this order: files inTHEME_TEMPLATES_OVERRIDESfirst, then the theme'stemplates/. The default is[].
You can also extend templates from the theme using the {% extends %} directive with the !theme prefix, like this, bestie:
{% extends '!theme/article.html' %}
CSS_FILEβ specify the CSS file you want to load. The default is"main.css".
By default, two themes are available. You can specify them using the THEME setting or by passing the -t option to the pelican command:
notmyideasimple(a synonym for "plain text" :)
There are a number of other themes available at <https://github.com/getpelican/pelican-themes>. Pelican comes with pelican-themes <>, a small script for managing themes π
You can define your own theme, either by starting from scratch or by duplicating and modifying a pre-existing theme. Here is a guide on how to create your theme <> π¦
Following are example ways to specify your preferred theme:
# Specify name of a built-in theme
THEME = "notmyidea"
# Specify name of a theme installed via the pelican-themes tool
THEME = "chunk"
# Specify a customized theme, via path relative to the settings file
THEME = "themes/mycustomtheme"
# Specify a customized theme, via absolute path
THEME = "/home/myuser/projects/mysite/themes/mycustomtheme"
π Simple Theme
The built-in simple theme can be customized using the following settings:
STYLESHEET_URLβ the URL of the stylesheet to use. The default isNone.
The built-in notmyidea theme can make good use of the following settings. Feel free to use them in your themes as well π
SITESUBTITLEβ a subtitle to appear in the header. The default isNone.DISQUS_SITENAMEβ Pelican can handle Disqus comments. Specify the Disqus sitename identifier here. The default isNone.GITHUB_URLβ your GitHub URL (if you have one). It will then use this information to create a GitHub ribbon β¨ The default isNone.ANALYTICSβ put any desired analytics scripts in this setting inpublishconf.py. Example:
ANALYTICS = """
<script src="/theme/js/primary-analytics.js"></script>
<script>
[ β¦ in-line Javascript code for secondary analytics β¦ ]
</script>
"""
The default is None.
MENUITEMSβ a list of tuples (Title, URL) for additional menu items to appear at the beginning of the main menu. The default isNone.LINKSβ a list of tuples (Title, URL) for links to appear on the header. The default isNone.SOCIALβ a list of tuples (Title, URL) to appear in the "social" section. The default isNone.TWITTER_USERNAMEβ allows for adding a button to articles to encourage others to tweet about them π add your Twitter username if you want this button to appear. The default isNone.LINKS_WIDGET_NAMEβ allows override of the name of the links widget. If not specified, defaults to"links". The default isNone.SOCIAL_WIDGET_NAMEβ allows override of the name of the "social" widget. If not specified, defaults to"social". The default isNone.
π Notmyidea Theme
In addition, you can use the "wide" version of the notmyidea theme by adding the following to your configuration:
CSS_FILE = "wide.css"
π Logging
Sometimes, a long list of warnings may appear during site generation. Finding the meaningful error message in the middle of tons of annoying log output can be quite tricky π In order to filter out redundant log messages, Pelican comes with the LOG_FILTER setting.
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. Simply populate the list with the log messages you want to hide, and they will be filtered out π
For example:
import logging
LOG_FILTER = [(logging.WARN, "TAG_SAVE_AS is set to False")]
It is possible to filter out messages by a template. Check out source code to obtain a template.
For example:
import logging
LOG_FILTER = [(logging.WARN, "Empty alt attribute for image %s in %s")]
Warning: Silencing messages by templates is a dangerous feature. It is possible to unintentionally filter out multiple message types with the same template (including messages from future Pelican versions). Proceed with caution β οΈ
Note: This option does nothing if --debug is passed.
β‘ Reading Only Modified Content
To speed up the build process, Pelican can optionally read only articles and pages with modified content πββοΈπ¨
When Pelican is about to read some content source file:
- The hash or modification time information for the file from a previous build are loaded from a cache file if
LOAD_CONTENT_CACHEisTrue. These files are stored in theCACHE_PATHdirectory. If the file has no record in the cache file, it is read as usual. - The file is checked according to
CHECK_MODIFIED_METHOD:- If set to
"mtime", the modification time of the file is checked. - If set to a name of a function provided by the
hashlibmodule, e.g."md5", the file hash is checked. - If set to anything else or the necessary information about the file cannot be found in the cache file, the content is read as usual.
- If set to
- If the file is considered unchanged, the content data saved in a previous build corresponding to the file is loaded from the cache, and the file is not read.
- If the file is considered changed, the file is read and the new modification information and the content data are saved to the cache if
CACHE_CONTENTisTrue.
If CONTENT_CACHING_LAYER is set to "reader" (the default), the raw content and metadata returned by a reader are cached. If this setting is instead set to "generator", the processed content object is cached. Caching the processed content object may conflict with plugins (as some reading related signals may be skipped) and the WITH_FUTURE_DATES functionality (as the draft status of the cached content objects would not change automatically over time).
Checking modification times is faster than comparing file hashes, but it is not as reliable because mtime information can be lost, e.g., when copying content source files using the cp or rsync commands without the mtime preservation mode (which for rsync can be invoked by passing the --archive flag). π«Ά
The cache files are Python pickles, so they may not be readable by different versions of Python as the pickle format often changes. If such an error is encountered, it is caught and the cache file is rebuilt automatically in the new format. The cache files will also be rebuilt after the GZIP_CACHE setting has been changed.
The --ignore-cache command-line option is useful when the whole cache needs to be regenerated, such as when making modifications to the settings file that will affect the cached content, or just for debugging purposes. When Pelican runs in autoreload mode, modification of the settings file will make it ignore the cache automatically if AUTORELOAD_IGNORE_CACHE is True.
Note that even when using cached content, all output is always written, so the modification times of the generated *.html files will always change. Therefore, rsync-based uploading may benefit from the --checksum option.
π Example settings
AUTHOR = "Alexis MΓ©taireau"
SITENAME = "Alexis' log"
SITESUBTITLE = "A personal blog."
SITEURL = "http://blog.notmyidea.org"
TIMEZONE = "Europe/Paris"
# can be useful in development, but set to False when you're ready to publish
RELATIVE_URLS = True
GITHUB_URL = "http://github.com/ametaireau/"
DISQUS_SITENAME = "blog-notmyidea"
REVERSE_CATEGORY_ORDER = True
LOCALE = "C"
DEFAULT_PAGINATION = 4
DEFAULT_DATE = (2012, 3, 2, 14, 1, 1)
FEED_ALL_RSS = "feeds/all.rss.xml"
CATEGORY_FEED_RSS = "feeds/{slug}.rss.xml"
LINKS = [
("Biologeek", "http://biologeek.org"),
("Filyb", "http://filyb.info/"),
("Libert-fr", "http://www.libert-fr.com"),
("N1k0", "http://prendreuncafe.com/blog/"),
("Tarek ZiadΓ©", "http://ziade.org/blog"),
("Zubin Mithra", "http://zubin71.wordpress.com/"),
]
SOCIAL = [
("twitter", "http://twitter.com/ametaireau"),
("lastfm", "http://lastfm.com/user/akounet"),
("github", "http://github.com/ametaireau"),
]
# global metadata to all the contents
DEFAULT_METADATA = {"yeah": "it is"}
# path-specific metadata
EXTRA_PATH_METADATA = {
"extra/robots.txt": {"path": "robots.txt"},
}
# static paths will be copied without parsing their contents
STATIC_PATHS = [
"images",
"extra/robots.txt",
]
# custom page generated with a jinja2 template
TEMPLATE_PAGES = {"pages/jinja2_template.html": "jinja2_template.html"}
# there is no other HTML content
READERS = {"html": None}
# code blocks with line numbers
PYGMENTS_RST_OPTIONS = {"linenos": "table"}
# foobar will not be used, because it's not in caps. All configuration keys
# have to be in caps
foobar = "barbaz"
π§© Plugins
Beginning with version 3.0, Pelican supports plugins. Plugins are a way to add features to Pelican without having to directly modify the Pelican core β¨
π How to use plugins
Starting with version 4.5, Pelican moved to a new plugin structure utilizing namespace packages that can be easily installed via Pip <https://pip.pypa.io/>. Plugins supporting this structure will install under the namespace package pelican.plugins and can be automatically discovered by Pelican. To see a list of Pip-installed namespace plugins that are active in your environment, run:
pelican-plugins
If you leave the PLUGINS setting as default (None), Pelican will automatically discover namespace plugins and register them π«Ά If, on the other hand, you specify a PLUGINS setting as a list of plugins, this auto-discovery will be disabled. At that point, only the plugins you specify will be registered, and you must explicitly list any namespace plugins as well π
okay so if youβre using the PLUGINS setting, bestie, you can specify plugins in two ways. The first method specifies plugins as a list of strings. Namespace plugins can be specified either by their full names (pelican.plugins.myplugin) or by their short names (myplugin):
PLUGINS = ['package.myplugin',
'namespace_plugin1',
'pelican.plugins.namespace_plugin2']
Alternatively, you can import them in your settings file and pass the modules:
from package import myplugin
from pelican.plugins import namespace_plugin1, namespace_plugin2
PLUGINS = [myplugin, namespace_plugin1, namespace_plugin2]
Note: when youβre experimenting with different plugins β especially the ones that deal with metadata and content β caching may interfere and the changes may not be visible π. In such cases disable caching withLOAD_CONTENT_CACHE = Falseor use the--ignore-cachecommand-line switch. trust, this one saves lives π
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 the PLUGIN_PATHS list can be absolute or relative to the settings file:
PLUGIN_PATHS = ["plugins", "/srv/pelican/plugins"]
PLUGINS = ["assets", "liquid_tags", "sitemap"]
π Where to find plugins
Namespace plugins can be found in the pelican-plugins organization at https://github.com/pelican-plugins as individual repositories. Legacy plugins are located in the pelican-plugins repository at https://github.com/getpelican/pelican-plugins and will be gradually phased out in favor of the namespace versions.
Please note that while we do our best to review and maintain these plugins, they are submitted by the Pelican community and thus may have varying levels of support and interoperability. iykyk π«Ά
Community plugins can also be found on PyPI tagged with "Framework :: Pelican :: Plugins" at https://pypi.org/search/?q=&o=-created&c=Framework+%3A%3A+Pelican+%3A%3A+Plugins.
π§ How to create plugins
Plugins are based on the concept of signals. Pelican sends signals, and plugins subscribe to those signals. The list of available signals is documented in a subsequent section. main character energy for real β¨
The only rule to follow for plugins is to define a register callable, in which you map the signals to your plugin logic. Letβs take a simple example:
import logging
from pelican import signals
log = logging.getLogger(__name__)
def test(sender):
log.debug("%s initialized !!", sender)
def register():
signals.initialized.connect(test)
Note: signal receivers are weakly-referenced and thus must not be defined within your register callable or they will be garbage-collected before the signal is emitted. do not do it, bestie π
If multiple plugins connect to the same signal, plugins will be invoked in the order they are registered. When the PLUGINS setting is defined, plugin invocation order will be the order in which the plugins are listed in the PLUGINS setting. If you rely on auto-discovered namespace plugins and have no PLUGINS setting defined, plugins will be invoked in the same order that they are discovered (the same order as listed in the output of the pelican-plugins command). If you want to specify the order explicitly, disable auto-discovery by defining PLUGINS in the desired order. order matters, periodt π
ποΈ Namespace plugin structure
Namespace plugins must adhere to a certain structure in order to function properly. They need to be installable (i.e. contain setup.py or equivalent) and have a folder structure as follows:
myplugin
βββ pelican
β βββ plugins
β βββ myplugin
β βββ __init__.py
β βββ ...
βββ ...
βββ setup.py
It is crucial that pelican or pelican/plugins folder not contain an __init__.py file. In fact, it is best to have those folders empty besides the listed folders in the above structure and keep your plugin related files contained solely in the pelican/plugins/myplugin folder to avoid any issues. this is the vibe check π¦
To easily set up the proper structure, a cookiecutter template for plugins at https://github.com/getpelican/cookiecutter-pelican-plugin is provided. Refer to that projectβs README for instructions on how to use it.
π‘ List of signals
Here is the list of currently implemented signals:
initializedβ arguments:pelican object; description: (none listed).finalizedβ arguments:pelican object; description: invoked after all the generators are executed and just before pelican exits, useful for custom post processing actions, such as:- minifying js/css assets.
- notify/ping search engines with an updated sitemap.
generator_initβ arguments:generator; description: invoked in theGenerator.__init__.all_generators_finalizedβ arguments:generators; description: invoked after all the generators are executed and before writing output.readers_initβ arguments:readers; description: invoked in theReaders.__init__.article_generator_contextβ arguments:article_generator, metadata; description: invoked after the content and metadata for the article has been generated; use if you need to adjust the article metadata before it gets used by Pelican.article_generator_prereadβ arguments:article_generator; description: invoked before a article is read inArticlesGenerator.generate_context; use if code needs to do something before every article is parsed.article_generator_initβ arguments:article_generator; description: invoked in theArticlesGenerator.__init__.article_generator_pretaxonomyβ invoked by:article_generatorβ fires off before the categories and tags lists get created. Super useful when you're, like, modifying the list of articles to be generated so that removed articles don't leak into categories or tags. no cap π«Άarticle_generator_finalizedβ invoked by:article_generatorβ gets invoked at the end ofArticlesGenerator.generate_context.article_generator_write_articleβ invoked by:article_generator,contentβ invoked before writing each article, and the article is passed ascontent. πarticle_writer_finalizedβ invoked by:article_generator,writerβ invoked after all articles and related pages have been written, but before the article generator is closed.get_generatorsβ invoked by:pelicanobject β invoked inPelican.get_generator_classes. Can return aGenerator, or several generators in a tuple or in a list. slay, options β¨get_writerβ invoked by:pelicanobject β invoked inPelican.get_writer. Can return a customWriter.page_generator_contextβ invoked by:page_generator,metadataβ no blurb for this one in the source, bestie, it's giving mystery πpage_generator_prereadβ invoked by:page_generatorβ invoked before a page is read inPageGenerator.generate_context. Use it if your code needs to do something before every page is parsed. πpage_generator_initβ invoked by:page_generatorβ invoked in thePagesGenerator.__init__.page_generator_finalizedβ invoked by:page_generatorβ invoked at the end ofPagesGenerator.generate_context.page_generator_write_pageβ invoked by:page_generator,contentβ invoked before writing each page, and the page is passed ascontent. π¦page_writer_finalizedβ invoked by:page_generator,writerβ invoked after all pages have been written, but before the page generator is closed.static_generator_contextβ invoked by:static_generator,metadataβ another mystery one, no description given πstatic_generator_prereadβ invoked by:static_generatorβ invoked before a static file is read inStaticGenerator.generate_context. Use it if your code needs to do something before every static file is added to the staticfiles list. πstatic_generator_initβ invoked by:static_generatorβ invoked in theStaticGenerator.__init__.static_generator_finalizedβ invoked by:static_generatorβ invoked at the end ofStaticGenerator.generate_context.content_object_initβ invoked by:content_objectβ invoked at the end ofContent.__init__. β¨content_writtenβ invoked by:path,contextβ invoked each time a content file is written.feed_generatedβ invoked by:context,feedβ invoked each time a feed gets generated. Can be used to modify a feed object before it gets written. π₯feed_writtenβ invoked by:path,context,feedβ invoked each time a feed file is written.
and that's the whole signal table done, bestie π«Ά lowkey iconic how many hooks there are β but wait, there's more coming so don't go anywhere π
Warning: bestie, do not reach for thecontent_object_initsignal if you're planning to read thesummaryorcontentproperties of the content object. That combo can leave you with unresolved links when you'reLinking to internal content <# ref-linking-to-internal-content>(see pelican-plugins bug #314 athttps://github.com/getpelican/pelican-plugins/issues/314). Use the_summaryand_contentproperties instead, or, alternatively, run your plugin at a later stage (e.g.all_generators_finalized). π
Note: After Pelican 3.2, signal names were standardized. Older plugins may need a glow-up to use the new names:
article_generate_contextβarticle_generator_contextarticle_generate_finalizedβarticle_generator_finalizedarticle_generate_prereadβarticle_generator_prereadpages_generate_contextβpage_generator_contextpages_generate_prereadβpage_generator_prereadpages_generator_finalizedβpage_generator_finalizedpages_generator_initβpage_generator_initstatic_generate_contextβstatic_generator_contextstatic_generate_prereadβstatic_generator_preread
π Recipes π
We eventually realised some of the recipes to create plugins would be best shared in the documentation somewhere, so here they are! no cap, these are the good stuff
π§ How to create a new reader π§
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 wisely chose to avoid this situation and instead have the different readers defined via plugins.
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.
No more talking β here is an example:
from pelican import signals
from pelican.readers import BaseReader
# Create a new reader class, inheriting from the pelican.reader.BaseReader
class NewReader(BaseReader):
enabled = True # Yeah, you probably want that :-)
# The list of file extensions you want this reader to match with.
# If multiple readers were to use the same extension, the latest will
# win (so the one you're defining here, most probably).
file_extensions = ['yeah']
# You need to have a read method, which takes a filename and returns
# some content and the associated metadata.
def read(self, filename):
metadata = {'title': 'Oh yeah',
'category': 'Foo',
'date': '2012-12-01'}
parsed = {}
for key, value in metadata.items():
parsed[key] = self.process_metadata(key, value)
return "Some content", parsed
def add_reader(readers):
readers.reader_classes['yeah'] = NewReader
# This is how pelican works.
def register():
signals.readers_init.connect(add_reader)
π₯ Adding a new generator π₯
Adding a new generator is also really easy. You might want to have a look at Pelican internals <> for more information on how to create your own generator.
def get_generators(pelican_object):
# define a new generator here if you need to
return MyGenerator
def register():
signals.get_generators.connect(get_generators)
π Adding a new writer π
Adding a writer will allow you to output additional file formats to disk, or change how the existing formats are written to disk. Note that only one writer will be active at a time, so be sure to either subclass the built-in Writer, or completely re-implement it.
Here is a basic example of how to set up your own writer:
from pelican.writers import Writer
from pelican import signals
class MyWriter(Writer):
# define new writer functionality
pass
def add_writer(pelican_object):
# use pelican_instance to setup stuff if needed
return MyWriter
def register():
signals.get_writer.connect(add_writer)
π¦ Using Plugins to Inject Content π¦
You can programmatically inject articles or pages using plugins. This can be useful if you plan to fetch articles from an API, for example.
Following is a simple example of how one can build a plugin that injects a custom article, using the article_generator_pretaxonomy signal:
import datetime
from pelican import signals
from pelican.contents import Article
from pelican.readers import BaseReader
def addArticle(articleGenerator):
settings = articleGenerator.settings
# Author, category, and tags are objects, not strings, so they need to
# be handled using BaseReader's process_metadata() function.
baseReader = BaseReader(settings)
content = "I am the body of an injected article!"
newArticle = Article(content, {
"title": "Injected Article!",
"date": datetime.datetime.now(),
"category": baseReader.process_metadata("category", "fromAPI"),
"tags": baseReader.process_metadata("tags", "tagA, tagB")
})
articleGenerator.articles.insert(0, newArticle)
def register():
signals.article_generator_pretaxonomy.connect(addArticle)
πΈ Themes πΈ
There is a community-managed repository of Pelican Themes at https://github.com/getpelican/pelican-themes for people to share and use.
Please note that while we do our best to review and merge theme contributions, they are submitted by the Pelican community and thus may have varying levels of support and interoperability.
Community themes can also be found on PyPI tagged with Framework :: Pelican :: Themes at https://pypi.org/search/?q=&o=-created&c=Framework+%3A%3A+Pelican+%3A%3A+Themes.
π Creating Themes π
To generate its HTML output, Pelican uses the Jinja templating engine due to its flexibility and straightforward syntax. If you want to create your own theme, feel free to take inspiration from the simple theme at https://github.com/getpelican/pelican/tree/main/pelican/themes/simple/templates.
To generate your site using a theme you have created (or downloaded manually and then modified), you can specify that theme via the -t flag:
pelican content -s pelicanconf.py -t /projects/your-site/themes/your-theme
If you'd rather not specify the theme on every invocation, you can define THEME in your settings to point to the location of your preferred theme.
π§΅ Structure π§΅
To make your own theme, you must follow the following structure:
βββ static
β βββ css
β βββ images
βββ templates
βββ archives.html // to display archives
βββ article.html // processed for each article
βββ author.html // processed for each author
βββ authors.html // must list all the authors
βββ categories.html // must list all the categories
βββ category.html // processed for each category
βββ index.html // the index (list all the articles)
βββ page.html // processed for each page
βββ period_archives.html // to display time-period archives
βββ tag.html // processed for each tag
βββ tags.html // must list all the tags. Can be a tag cloud.
staticcontains all the static assets, which will be copied to the output theme folder. The above filesystem layout includes CSS and image folders, but those are just examples. Put what you need here.templatescontains all the templates that will be used to generate the content. The template files listed above are mandatory; you can add your own templates if it helps you keep things organized while creating your theme.
β¨ Templates and Variables β¨
The idea is to use a simple syntax that you can embed into your HTML pages. This document describes which templates should exist in a theme, and which variables will be passed to each template at generation time.
All templates will receive the variables defined in your settings file, as long as they are in all-caps. You can access them directly.
output_fileβ the name of the file that's being generated right now. Like, when Pelican is rendering your home page,output_fileis literally"index.html". That's it, that's the whole vibe. πarticlesβ the list of articles, ordered descending by date (newest first, main character energy π). Every element in there is anArticleobject, so you can grab their attributes:title,summary,author, all of it. β οΈ Heads up bestie: sometimes this one gets shadowed β for example on the tags page. When that happens, the info you're looking for is chilling over in theall_articlesvariable instead. iykyk.datesβ same list of articles, same objects, but ordered by date ascending. The little sibling ofarticles. π§hidden_articlesβ the list of hidden articles πdraftsβ the list of draft articles β¨period_archivesβ a dictionary holding the elements related to time-period archives (if enabled β no cap, only if you turned it on). Peep the section Listing and Linking to Period Archives for the deets. ποΈauthorsβ a list of(author, articles)tuples, containing all the authors and their corresponding articles as the values π«Άcategoriesβ a list of(category, articles)tuples, containing all the categories and their corresponding articles as the values πtagsβ a list of(tag, articles)tuples, containing all the tags and their corresponding articles as the values π¦pagesβ the list of pages βhidden_pagesβ the list of hidden pages πΈdraft_pagesβ the list of draft pages π
π Sorting
Okay so URL wrappers β currently categories, tags, and authors β come with comparison methods that let you sort them by name so easily, it's giving effortless:
{% for tag, articles in tags|sort %}
But say you wanna sort on totally different criteria β Jinja's own sort command has a whole bunch of options for you. Docs live at https://jinja.palletsprojects.com/en/latest/templates/#sort if you wanna go read up. π
π Date Formatting
Pelican formats the date based on your settings and your locale (DATE_FORMATS/DEFAULT_DATE_FORMAT), and it hands you a locale_date attribute for that. Meanwhile the date attribute is a whole datetime object β as in https://docs.python.org/3/library/datetime.html#datetime-objects.
So if you need β¨customβ¨ formatting for a date, something different from your settings? Use the Jinja filter strftime that ships with Pelican. Usage is identical to Python's strftime β https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior β but the filter does the right thing and formats your date according to the locale you set in your settings. Iconic behaviour, honestly:
{{ article.date|strftime('%d %B %Y') }}
π Checking Loaded Plugins
Pelican gives you a plugin_enabled Jinja test so you can check whether a certain plugin is enabled. The test takes a plugin name as a string and returns a Boolean. Namespace plugins can be specified by full name (pelican.plugins.plugin_name) or by short name (plugin_name). π«Ά
Below, the webassets plugin minifies the CSS if the plugin is enabled β and if it's not, we just fall back to regular CSS like nothing happened:
{% if "webassets" is plugin_enabled %}
{% assets filters="cssmin", output="css/style.min.css", "css/style.scss" %}
<link rel="stylesheet" href="{{SITEURL}}/{{ASSET_URL}}">
{% endassets %}
{% else %}
<link rel="stylesheet" href="{{SITEURL}}/css/style.css}">
{% endif %}
π index.html
This is the home page β the index of your blog, bestie β generated at index.html. Main character file fr fr π
If pagination is active, the subsequent pages live at index{number}.html. β¨
But likeβ¦ what actually gets handed to your template? Here's the whole vibe check π
articles_paginatorβ a paginator object for the list of articlesarticles_pageβ the current page of articlesarticles_previous_pageβ the previous page of articles (Noneif that page does not exist)articles_next_pageβ the next page of articles (Noneif that page does not exist)dates_paginatorβ a paginator object for the article list, ordered by date, ascending.dates_pageβ the current page of articles, ordered by date, ascending.dates_previous_pageβ the previous page of articles, ordered by date, ascending (Noneif that page does not exist)dates_next_pageβ the next page of articles, ordered by date, ascending (Noneif that page does not exist)page_nameβ'index'β genuinely so useful for your pagination links π
π¦ author.html
Okay so this one gets processed for each of the existing authors β one pass per author, bestie β and the output gets generated according to the AUTHOR_SAVE_AS setting (default: author/{slug}.html). And if pagination is active, the subsequent pages will by default reside at author/{slug}{number}.html. Noted. π
Here's what's in scope inside it:
authorβ the name of the author being processedarticlesβ articles by this authordatesβ articles by this author, but ordered by date, ascendingarticles_paginatorβ a paginator object for the list of articlesarticles_pageβ the current page of articlesarticles_previous_pageβ the previous page of articles (Noneif that page does not exist)articles_next_pageβ the next page of articles (Noneif that page does not exist)dates_paginatorβ a paginator object for the article list, ordered by date, ascending.dates_pageβ the current page of articles, ordered by date, ascending.dates_previous_pageβ the previous page of articles, ordered by date, ascending (Noneif that page does not exist)dates_next_pageβ the next page of articles, ordered by date, ascending (Noneif that page does not exist)page_nameβAUTHOR_URLwhere everything after{slug}is removed β lowkey the move for pagination links π«Ά
Heads up:page_namehere is not the same as onindex.html. On the index it's literally'index'; here it'sAUTHOR_URLwith everything after{slug}chopped off. Don't mix them up, iykyk. π
category.html π·οΈ
This one gets processed once for every category that actually exists, and the output goes wherever your CATEGORY_SAVE_AS setting points β which defaults to category/{slug}.html. And if pagination is turned on, the follow-up pages hang out at category/{slug}{number}.html by default. Slay. π
Here's every variable you get to play with while rendering:
categoryβ the name of the category currently being processed β¨articlesβ the articles that belong to this categorydatesβ same category's articles, but sorted by date, ascending ποΈarticles_paginatorβ a paginator object for the list of articlesarticles_pageβ the current page of articlesarticles_previous_pageβ the previous page of articles (Noneif that page doesn't exist, no cap)articles_next_pageβ the next page of articles (Noneif it doesn't exist either)dates_paginatorβ a paginator object for the list of articles ordered by date, ascendingdates_pageβ the current page of articles, ordered by date, ascendingdates_previous_pageβ the previous page of articles ordered by date ascending (Noneif no such page π)dates_next_pageβ the next page of articles ordered by date ascending (Noneif it's not there)page_nameβ literallyCATEGORY_URLwith everything after{slug}chopped off β so useful for your pagination links π«Ά
article.html π
Obsessed with this one β it gets processed for each article, and the output lands wherever ARTICLE_SAVE_AS says (Default: {slug}.html). Here's what's available when rendering:
articleβ the article object being displayed πcategoryβ the name of the category for the current article
Now the fun part: any metadata you drop in the header of the article source file becomes a field on the article object. The field name is the same as the metadata field name, except it's all-lowercase characters. iykyk.
So like, say you add a field called FacebookImage to your article metadata, like this:
Title: I love Python more than music
Date: 2013-11-06 10:06
Tags: personal, python
Category: Tech
Slug: python-je-l-aime-a-mourir
Author: Francis Cabrel
FacebookImage: http://franciscabrel.com/images/pythonlove.png
That new metadata is now available as article.facebookimage in your article.html template π. Which means you can do stuff like set an image for the Facebook open graph tags that changes per article:
<meta property="og:image" content="{{ article.facebookimage }}"/>
Not me making every article have its own custom OG image π iconic behaviour fr fr.
page.html π
This template gets processed for each page, and the output is generated according to the PAGE_SAVE_AS setting (Default: pages/{slug}.html). Variable time, and there's just the one:
pageβ the page object to be displayed. You can access its title, slug, and content. πΈ
That's it, that's the whole vibe check for this one β one variable, zero stress, we love a low-maintenance template π¦.
πΈ tag.html
ok so this one gets processed for every single tag, and the output lands wherever your TAG_SAVE_AS setting says it should (default is tag/{slug}.html, iconic). And if pagination is turned on, the follow-up pages live at tag/{slug}{number}.html by default. slay.
tagβ the name of the tag currently being processed, obviarticlesβ all the articles that belong to this tag πdatesβ same articles, same tag, but sorted by date, ascendingarticles_paginatorβ a paginator object for the list of articlesarticles_pageβ the current page of articlesarticles_previous_pageβ the previous page of articles (Noneif that page doesn't exist, π)articles_next_pageβ the next page of articles (Noneif that page doesn't exist either)dates_paginatorβ a paginator object for the list of articles, ordered by date, ascendingdates_pageβ the current page of articles, ordered by date, ascendingdates_previous_pageβ the previous page of articles, ordered by date, ascending (Noneif the page doesn't exist)dates_next_pageβ the next page of articles, ordered by date, ascending (Noneif the page doesn't exist)page_nameβTAG_URLwith everything after{slug}chopped off β literally made for pagination links, chef's kiss π
π¦ period_archives.html
this template gets processed once for each year of your posts if you've defined a path for YEAR_ARCHIVE_SAVE_AS, once for each month if MONTH_ARCHIVE_SAVE_AS is defined, and once for each day if DAY_ARCHIVE_SAVE_AS is defined. so like, it matches whatever you turned on.
periodβ a tuple shaped like(year, month, day)that tells you which time period you're in.yearanddayare numbers, butmonthis a string (yes, messy, we know). this tuple only holdsyearif the time period is a given year; it holds bothyearandmonthif the time period spans years and months, and so on π«Άperiod_numβ a tuple shaped like(year, month, day), same asperiod, except all the values are numbers
there's a whole example of how to use period in the "simple" theme's period_archives.html template at https://github.com/getpelican/pelican/blob/main/pelican/themes/simple/templates/period_archives.html if you wanna peep it β¨
π Listing and Linking to Period Archives
okay so period_archives is your girl for generating a list of links to all the period archives Pelican builds. she's a common variable, meaning she's available in any template, so you can drop that index into a custom direct template or stick it in a sidebar that shows up across your whole site. main character energy fr.
period_archives is a dict that may contain year, month, and/or day keys, depending on which *_ARCHIVE_SAVE_AS settings you've got enabled. each of those keys holds a list of dicts, and every dict in that list represents one time period β ordered according to the NEWEST_FIRST_ARCHIVES setting β with these keys and values π
periodβ the same tuple described up inperiod_archives.html, e.g.(2023, 'June', 18)period_numβ the same tuple described up inperiod_archives.html, e.g.(2023, 6, 18)urlβ the URL to the period archive page, e.g.posts/2023/06/18/. this one's controlled by the corresponding*_ARCHIVE_URLsetting πsave_asβ the path to where the period archive page file gets saved, e.g.posts/2023/06/18/index.html. Pelican uses this internally, so it's usually not relevant to themes (iykyk, most of y'all can ignore it)articlesβ a list ofArticleobjects that fall under that time perioddatesβ same list asarticles, but ordered according to theNEWEST_FIRST_ARCHIVESsetting
and here's an example of how period_archives can be used in a template, bestie:
<ul>
{% for archive in period_archives.month %}
<li>
<a href="{{ SITEURL }}/{{ archive.url }}">
{{ archive.period | reverse | join(' ') }} ({{ archive.articles|count }})
</a>
</li>
{% endfor %}
</ul>
okay so that loop is literally just vibing there and you can shuffle it around π
like, take period_archives.month in that for statement and swap it for period_archives.year or period_archives.day instead β whichever one matches the time-period granularity you actually want. pick your fighter, bestie π
π§Έ Objects
so here's the tea β β these are the detail-object attributes that are actually available and genuinely useful inside your templates. Heads up tho: this is not the whole list, it's a curated selection of the attributes that are considered useful in a template π don't come for me if something's missing.
π Article
the string representation of an Article? that's the source_path attribute. iconic behaviour honestly π
authorβ the Author of this article πauthorsβ a whole list of Authors of this article (plural era)categoryβ the Category of this articlecontentβ the rendered content of the article β¨dateβ a Datetime object representing the article datedate_formatβ either the default date format or the locale date formatdefault_templateβ default template namein_default_langβ a Boolean, true/false style, representing if the article is written in the default language πlangβ language of the articlelocale_dateβ the date formatted by thedate_formatmetadataβ article header metadata dictsave_asβ location to save the article pageslugβ page slugsource_pathβ full system path of the article source filerelative_source_pathβ relative path fromPATH <settings.html#PATH>to the article source filestatusβ the article status, can be any of'published'or'draft'πsummaryβ rendered summary contenttagsβ list of Tag objectstemplateβ template name to use for renderingtitleβ title of the article πΈtranslationsβ list of translations Article objectsurlβ URL to the article page π
π·οΈ Author / Category / Tag
and for these three cuties, the string representation is the name attribute π«Ά
nameβ name of this object [1]page_nameβ author page namesave_asβ location to save the author pageslugβ page slugurlβ URL to the author page
[1] for Author object, coming from:authors:orAUTHOR. π
π¦ Page π¦
The string representation of a Page is the source_path attribute, periodt.
authorβ the author of this page, aka who wrote it πββοΈcontentβ the rendered content of the page, the whole vibe β¨dateβ a Datetime object representing the page date, time-stamped bestie πdate_formatβ either the default date format or the locale date format, iykykdefault_templateβ default template name, no capin_default_langβ Boolean representing if the article is written in the default language, true or false tea βlangβ language of the article, the lingo πlocale_dateβ date formatted by thedate_format, slaymetadataβ Page header metadata dict, all the deets πsave_asβ location to save the page, where it lives πslugβ page slug, the URL-friendly nickname πsource_pathβ full system path of the page source file, the real address πΊοΈrelative_source_pathβ relative path fromPATH<settings.html#PATH> to the page source file, the shortcut vibestatusβ the page status, can be any of'published','hidden'or'draft', choose your fighter πsummaryβ rendered summary content, the TL;DR β¨tagsβ list of Tag objects, all the labels π·οΈtemplateβ template name to use for rendering, the look πtitleβ title of the page, the main character energy πtranslationsβ list of translations Article objects, multilingual queen πurlβ URL to the page, the link bestie π
π Feeds π
The feed variables changed in 3.0, bestie. Each variable now explicitly lists ATOM or RSS in the name. ATOM is still the default, so no stress. Old themes will need to be updated β sorry not sorry, glow-up required π . Here is a complete list of the feed variables:
AUTHOR_FEED_ATOMAUTHOR_FEED_RSSCATEGORY_FEED_ATOMCATEGORY_FEED_RSSFEED_ALL_ATOMFEED_ALL_RSSFEED_ATOMFEED_RSSTAG_FEED_ATOMTAG_FEED_RSSTRANSLATION_FEED_ATOMTRANSLATION_FEED_RSS
𧬠Inheritance π§¬
Since version 3.0, Pelican supports inheritance from the simple theme, so you can re-use the simple theme templates in your own themes. Literally the bestie upgrade π«Ά.
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. So if the HTML structure of a template in the simple theme is right for you, you don't have to write a new template from scratch. Thank u, next π.
You can also extend templates from the simple theme in your own themes by using the {% extends %} directive as in the following example:
{% extends "!simple/index.html" %} <!-- extends the ``index.html`` template from the ``simple`` theme -->
{% extends "index.html" %} <!-- "regular" extending -->
π Example π
With this system, it is possible to create a theme with just one file. One file! Iconic.
π main.css π
The file is static/css/main.css (the default CSS_FILE):
body {
font-family : monospace ;
font-size : 100% ;
background-color : white ;
color : #111 ;
width : 80% ;
min-width : 400px ;
min-height : 200px ;
padding : 1em ;
margin : 5% 10% ;
border : thin solid gray ;
border-radius : 5px ;
display : block ;
}
a:link { color : blue ; text-decoration : none ; }
a:hover { color : blue ; text-decoration : underline ; }
a:visited { color : blue ; }
h1 a { color : inherit !important }
h2 a { color : inherit !important }
h3 a { color : inherit !important }
h4 a { color : inherit !important }
h5 a { color : inherit !important }
h6 a { color : inherit !important }
pre {
margin : 2em 1em 2em 4em ;
}
#menu li {
display : inline ;
}
#post-list {
margin-bottom : 1em ;
margin-top : 1em ;
}
π¦ Custom templates π¦
If you want to customise the templates as well, you can extend them. For example, to add a custom footer, create a templates/base.html:
{% extends "!simple/base.html" %}
{% block footer %}
<p>Custom footer</p>
{{ super() }}
{% endblock %}
- On the first line, we extend the
base.htmltemplate from thesimpletheme, so we don't have to rewrite the entire file. Slay. - On the third line, we open the
footerblock which has already been defined in thesimpletheme. - On the fourth line, we insert the extra footer content.
- On the fifth line, the function
super()keeps the content previously inserted in theheadblock. (Yes,headblock β that's what it says, bestie.) - On the last line, we close the
footerblock.
This file will be extended by all the other templates, so the custom footer will appear on all pages. Main character energy for real.
π pelican-themes π
π Description π
pelican-themes is a command line tool for managing themes for Pelican. See Themes <#settings-themes> for settings related to themes. It's giving theme manager realness.
πΈ Usage πΈ
pelican-themes [-h] [-l] [-i theme path [theme path ...]]
[-r theme name [theme name ...]]
[-s theme path [theme path ...]] [-v] [--version]
β¨ Optional arguments: β¨
-h,--helpβ show the help and exit, the ultimate "what do I do" button π-l,--listβ show the themes already installed, a little show-and-tell π-i theme_path,--install theme_pathβ one or more themes to install, new aesthetic unlocked β¨-r theme_name,--remove theme_nameβ one or more themes to remove, bye felicia π-s theme_path,--symlink theme_pathβ same as--install, but create a symbolic link instead of copying the theme. Useful for theme development, devs stay winning π οΈ-v,--verboseβ verbose output, tell me everything bestie π£οΈ--versionβ print the version of this script, the receipts π§Ύ
π Examples π
π Listing the installed themes π
With pelican-themes, you can see the available themes by using the -l or --list option:
$ pelican-themes -l
notmyidea
two-column@
simple
$ pelican-themes --list
notmyidea
two-column@
simple
In this example, we can see there are three themes available: notmyidea, simple, and two-column. The way that's a whole collection π.
two-column is followed by 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). Symbolic link realness, iykyk π.
ok so quick lil pro tip before we move on: you can totally pair the --list option with -v or --verbose to get the spicy detailed output, like this:
$ pelican-themes -v -l
/usr/local/lib/python2.6/dist-packages/pelican-2.6.0-py2.6.egg/pelican/themes/notmyidea
/usr/local/lib/python2.6/dist-packages/pelican-2.6.0-py2.6.egg/pelican/themes/two-column (symbolic link to `/home/skami/Dev/Python/pelican-themes/two-column')
/usr/local/lib/python2.6/dist-packages/pelican-2.6.0-py2.6.egg/pelican/themes/simple
see how the symlink one snitches on itself?? iconic behavior tbh π
πΈ Installing themes πΈ
You can install one or more themes using the -i or --install option. It takes as argument the path(s) of the theme(s) you wanna install, and yeah it stacks with --verbose:
# pelican-themes --install ~/Dev/Python/pelican-themes/notmyidea-cms --verbose
# pelican-themes --install ~/Dev/Python/pelican-themes/notmyidea-cms\
~/Dev/Python/pelican-themes/martyalchin \
--verbose
# pelican-themes -vi ~/Dev/Python/pelican-themes/two-column
multiple paths at once?? we love a multitasker π«Ά
π Removing themes π
The pelican-themes command can also remove themes from the Pelican themes path. The -r or --remove option takes as argument the name(s) of the theme(s) you wanna yeet, and yes queen it can be combined with --verbose:
# pelican-themes --remove two-column
# pelican-themes -r martyachin notmyidea-cmd -v
(it takes the name, not the path, bestie β read the room π)
π¦ Creating symbolic links π¦
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, use the -s or --symlink option, which works exactly as the --install option does:
# 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 also we can modify it without having to reinstall it after each modification. no more reinstall-and-pray loop, we're so back πβ¨
This is literally the move for theme development:
$ sudo pelican-themes -s ~/Dev/Python/pelican-themes/two-column
$ pelican ~/Blog/content -o /tmp/out -t two-column
$ firefox /tmp/out/index.html
$ vim ~/Dev/Pelican/pelican-themes/two-column/static/css/main.css
$ pelican ~/Blog/content -o /tmp/out -t two-column
$ cp /tmp/bg.png ~/Dev/Pelican/pelican-themes/two-column/static/img/bg.png
$ pelican ~/Blog/content -o /tmp/out -t two-column
$ vim ~/Dev/Pelican/pelican-themes/two-column/templates/index.html
$ pelican ~/Blog/content -o /tmp/out -t two-column
edit β rebuild β refresh β repeat. the sacred cycle ππ₯
π Doing several things at once π
The --install, --remove and --symlink options are not mutually exclusive, so you can combine them in the same command line to do more than one operation at a time, like this:
# pelican-themes --remove notmyidea-cms two-column \
--install ~/Dev/Python/pelican-themes/notmyidea-cms-fr \
--symlink ~/Dev/Python/pelican-themes/two-column \
--verbose
In this example, the theme notmyidea-cms is replaced by the theme notmyidea-cms-fr.
one command, three operations, zero drama. main character energy fr fr π
π Importing an existing site π
β¨ Description β¨
pelican-import is a command-line tool for converting articles from other software to reStructuredText or Markdown. The supported import formats are:
- Blogger XML export
- Dotclear export
- Medium export
- Tumblr API
- WordPress XML export
- RSS/Atom feed
The conversion from HTML to reStructuredText or Markdown relies on Pandoc <https://pandoc.org/>. For Dotclear, if the source posts are written with Markdown syntax, they will not be converted (since Pelican also supports Markdown). so like, no notes, it's already fine π
Note: Unlike Pelican, WordPress supports multiple categories per article. These are imported as a comma-separated string. You have to resolve these manually, or use a plugin such as More Categories <https://github.com/pelican-plugins/more-categories> that enables multiple categories per article.
Note: Imported pages may contain links to images that still point to the original site. So you might want to download those images into your local content and manually re-link them from the relevant pages of your site. (annoying? yes. fixable? also yes π«Ά)
π§ Dependencies π§
pelican-import has some dependencies that the rest of Pelican doesn't need:
- BeautifulSoup4 and lxml, for WordPress and Dotclear import. Can be installed like any other Python package (
pip install BeautifulSoup4 lxml). - Feedparser, for feed import (
pip install feedparser). - Pandoc, see the Pandoc site <https://pandoc.org/installing.html> for installation instructions on your operating system.
π Usage π
pelican-import [-h] [--blogger] [--dotclear] [--tumblr] [--wpfile] [--feed]
[-o OUTPUT] [-m MARKUP] [--dir-cat] [--dir-page] [--strip-raw] [--wp-custpost]
[--wp-attach] [--disable-slugs] [-b BLOGNAME]
input|api_key
πΈ Positional arguments πΈ
inputβ the input file to readapi_keyβ (Tumblr only)api_keycan be obtained from <https://www.tumblr.com/oauth/apps>
β Optional arguments β
-h,--helpβ show this help message and exit--bloggerβ Blogger XML export (default:False)--dotclearβ Dotclear export (default:False)--mediumβ Medium export (default:False)--tumblrβ Tumblr API (default:False)--wpfileβ WordPress XML export (default:False)--feedβ feed to parse (default:False)-o OUTPUT,--output OUTPUTβ output path (default:content)-m MARKUP,--markup MARKUPβ output markup format:rst,markdown, orasciidoc(default:rst)--dir-catβ put files in directories with categories name (default:False)--dir-pageβ put files recognised as pages in"pages/"sub-directory (blogger and wordpress import only) (default:False)--filter-authorβ import only post from the specified author--strip-rawβ strip raw HTML code that can't be converted to markup such as flash embeds or iframes (default:False)--wp-custpostβ put wordpress custom post types in directories. If used with--dir-catoption directories will be created as"/post_type/category/"(wordpress import only)--wp-attachβ download files uploaded to wordpress as attachments. Files will be added to posts as a list in the post header and links to the files within the post will be updated. All files will be downloaded, even if they aren't associated with a post. Files will be downloaded with their original path inside the output directory, e.g."output/wp-uploads/date/postname/file.jpg". (wordpress import only) (requires an internet connection)--disable-slugsβ disable storing slugs from imported posts within output. With this disabled, your Pelican URLs may not be consistent with your original posts. (default:False)-b BLOGNAME,--blogname=BLOGNAMEβ blog name used in Tumblr API
π Examples π
For Blogger:
$ pelican-import --blogger -o ~/output ~/posts.xml
For Dotclear:
$ pelican-import --dotclear -o ~/output ~/backup.txt
For Medium:
$ pelican-import --medium -o ~/output ~/medium-export/posts/
The Medium export is a zip file. Unzip it, and point this tool to the "posts" subdirectory. For more information on how to export, see <https://help.medium.com/hc/en-us/articles/115004745787-Export-your-account-data>.
For Tumblr:
$ pelican-import --tumblr -o ~/output --blogname=<blogname> <api_key>
For WordPress:
$ pelican-import --wpfile -o ~/output ~/posts.xml
For Medium (an example of using an RSS feed):
$ python -m pip install feedparser $ pelican-import --feed <https://medium.com/feed/@username>
Note: The RSS feed may only return the most recent posts β not all of them. π the archive is not safe, bestie.
π¦ Tests π¦
To test the module, one can use sample files:
- for WordPress: <https://www.wpbeginner.com/wp-themes/how-to-add-dummy-content-for-theme-development-in-wordpress/>
- for Dotclear: <http://media.dotaddict.org/tda/downloads/lorem-backup.txt>
π Frequently Asked Questions (FAQ) π
Here are some frequently asked questions about Pelican.
π What's the best way to communicate a problem, question, or suggestion? π
Please read our feedback guidelines <>.
π How can I help? π
There are several ways to help out. First, you can communicate any Pelican suggestions or problems you might have via Pelican Discussions <https://github.com/getpelican/pelican/discussions>. Please first check the existing list of discussions and issues (both open and closed) in order to avoid submitting topics that have already been covered before. (iykyk β do the reading first, bestie π)
If you want to contribute, please fork the Git repository <https://github.com/getpelican/pelican/>, create a new feature branch, make your changes, and issue a pull request. Someone will review your changes as soon as possible. Please refer to the How to Contribute <> section for more details.
You can also contribute by creating themes and improving the documentation. themes and docs are so underrated and we love the people who do them π«Ά
π Is the Pelican settings file mandatory? π
Configuration files are optional and are just an easy way to configure Pelican. For basic operations, it's possible to specify options while invoking Pelican via the command line. See pelican --help for more information.
π Changes to the settings file take no effect π
When experimenting with different settings (especially the metadata ones) caching may interfere and the changes may not be visible. In such cases, ensure that caching is disabled via LOAD_CONTENT_CACHE = False or use the --ignore-cache command-line switch. the cache is gaslighting you β turn it off ππ₯
β¨ I'm creating my own theme. How do I use Pygments for syntax highlighting?
Ok so Pygments sprinkles some classes onto the generated content, and those classes are literally what your theme uses to style the code syntax highlighting via CSS. Specifically, you customize how your highlighting looks through the .highlight pre class in your theme's CSS file. Wanna see how the various styles render Django code? There's a style selector drop-down at the top-right of the Pygments project demo site <https://pygments.org/demo/> β go poke at it π
These example commands will generate a starter CSS file from a Pygments built-in style (in this case, "monokai") and then copy the generated CSS file over to your new theme:
pygmentize -S monokai -f html -a .highlight > pygment.css
cp pygment.css path/to/theme/static/css/
And don't forget to import your pygment.css file from your main CSS file, bestie β otherwise it's just sitting there doing nothing π
π How do I create my own theme?
Please refer to Themes <#theming-pelican>. That's the whole answer, no cap.
π¦ Can I override individual templates without forking the whole theme?
Yes! You can override existing templates of the theme you're using, or add brand-new ones, via the THEME_TEMPLATES_OVERRIDES variable. For example, to override the page template, you define the location for your templates like this:
THEME_TEMPLATES_OVERRIDES = ["templates"]
Then you just define a custom template in templates/page.html. See Themes <#settings-themes> for the details β¨
πΈ I want to use Markdown, but I got an error.
Classic. If you try to generate Markdown content without first installing the Markdown library, you may see a message that says No valid files found in content. Markdown is not a hard dependency for Pelican, so if you've got content in Markdown format, you'll need to explicitly install the Markdown library. You can do it by typing the following command, prepending sudo if permissions require it:
python -m pip install markdown
Slay, now your Markdown is actually gonna get read π₯
π Can I use arbitrary metadata in my templates?
Yes. For example, to include a modified date in a Markdown post, one could include the following at the top of the article:
Modified: 2012-08-08
For reStructuredText, this metadata should of course be prefixed with a colon:
:Modified: 2012-08-08
This metadata can then be accessed in templates such as article.html via:
{% if article.modified %}
Last modified: {{ article.modified }}
{% endif %}
If you want to include metadata in templates outside the article context (e.g., base.html), the if statement should instead be:
{% if article and article.modified %}
Note: because the colon symbol (:) is used as a separator, be aware that metadata field names containing a colon will probably not work. Sad but true π
π§ How do I make my output folder structure identical to my content hierarchy?
Try these settings:
USE_FOLDER_AS_CATEGORY = False
PATH_METADATA = r"(?P<path_no_ext>.*)\..*"
ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = "{path_no_ext}.html"
That's it, that's the vibe check π«Ά
β How do I assign custom templates on a per-page basis?
It's as simple as adding an extra line of metadata to any page or article that you want to have its own template. For example, this is how it would be handled for content in reST format:
:template: template_name
For content in Markdown format:
Template: template_name
Then just make sure your theme contains the relevant template file (e.g., template_name.html). And if you just want to add a new custom template to an existing theme, you can also provide it in a directory specified by THEME_TEMPLATES_OVERRIDES (see Themes <#settings-themes>) π
π How can I override the generated URL of a specific page or article?
Include url and save_as metadata in any pages or articles where you want to override the generated URL. Here's an example page in reST format:
Override url/save_as page
#########################
:url: override/url/
:save_as: override/url/index.html
With this metadata, the page will be written to override/url/index.html and Pelican will use the URL override/url/ to link to this page. Chef's kiss π
π How can I use a static page as my home page?
That override feature from above can be used to specify a static page as your home page. The following Markdown example could be stored in content/pages/home.md:
Title: Welcome to My Site
URL:
save_as: index.html
Thank you for visiting. Welcome!
If the original blog index is still wanted, it can then be saved in a different location by setting INDEX_SAVE_AS = 'blog_index.html' for the 'index' direct template. Iconic behaviour, honestly π
π What if I want to disable feed generation?
To disable feed generation, all feed settings should be set to None. All but three feed settings already default to None, so if you want to disable all feed generation, you only need to specify the following settings:
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
The wordNoneshould not be surrounded by quotes. Please note thatNoneand''are not the same thing β they are not even cousins, ok? π
π₯ I'm getting a warning about feeds generated without SITEURL being set properly
RSS and Atom feeds require all URL links to be absolute <https://validator.w3.org/feed/docs/rss2.html#comments>. In order to properly generate links in Pelican, you'll need to set SITEURL to the full path of your site.
Feeds are still generated when this warning is displayed, but links within may be malformed and thus the feed may not validate. So likeβ¦ it's giving "works but at what cost" π
π¦ Can I force Atom feeds to show only summaries instead of article content?
Instead of having to open a separate browser window to read articles, the overwhelming majority of folks who use feed readers prefer to read content within the feed reader itself. Mainly for that reason, Pelican does not support restricting Atom feeds to only contain summaries. Unlike Atom feeds, the RSS feed specification does not include a separate content field, so by default Pelican publishes RSS feeds that only contain summaries (but can optionally be set to instead publish full content RSS feeds). So the default feed generation behavior provides users with a choice: subscribe to Atom feeds for full content, or to RSS feeds for just the summaries. A little choose-your-own-adventure, cute right? β¨
π Is Pelican only suitable for blogs?
No. Pelican can be easily configured to create and maintain any type of static site. This may require a little customization of your theme and Pelican configuration. For example, if you're building a launch site for your product and don't need tags on your site, you could remove the relevant HTML code from your theme. You can also disable generation of tag-related pages via:
TAGS_SAVE_AS = ''
TAG_SAVE_AS = ''
Not just a blog girlie, she contains multitudes π
π Why does Pelican always write all HTML files even with content caching enabled?
Ok so this one's a whole thing. In order to reliably determine whether the HTML output is different before writing it, a large part of the generation environment β including the template contexts, imported plugins, etc. β would have to be saved and compared, at least in the form of a hash (which would require special handling of unhashable types), because of all the possible combinations of plugins, pagination, etc. which may change in many different ways. That would require a lot more processing time and memory and storage space. Simply writing the files each time is a lot faster and a lot more reliable.
However, this means the modification time of the files changes every time, so an rsync-based upload will transfer them even if their content hasn't changed. A simple solution is to make rsync use the --checksum option, which will make it compare the file checksums in a much faster way than Pelican would. Big brain energy π₯
π§ How to process only a subset of all articles?
It's often useful to process only e.g. 10 articles for debugging purposes. This can be achieved by explicitly specifying only the filenames of those articles in ARTICLE_PATHS. A list of such filenames could be found using a command similar to cd content; find -name '*.md' | head -n 10.
π My tag cloud is missing/broken since I upgraded Pelican
In an ongoing effort to streamline Pelican, tag cloud generation has been moved out of Pelican core and into a separate plugin <https://github.com/pelican-plugins/tag-cloud>. See the Plugins <#plugins> documentation for further information about the Pelican plugin system. She's independent now, living her own life π¦
πΈ Since I upgraded Pelican my pages are no longer rendered
Pages were available to themes as lowercase pages and uppercase PAGES. To bring this in line with the Templates and Variables <#templates-variables> section, PAGES has been removed. This is quickly resolved by updating your theme to iterate over pages instead of PAGES. Just replace:
{% for pg in PAGES %}
with something like:
{% for pg in pages %}
Lowercase era, we love to see it π
π How can I stop Pelican from trying to parse my static files as content?
Pelican's article and page generators run before its static generator. That 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 valid content file ending (.html, .rst, .md, ...) will be treated as articles or pages before they get treated as static files.
To circumvent this issue, either use the appropriate *_EXCLUDES setting or disable the offending reader via READERS if you don't need it. Pick your fighter π
β Why is [arbitrary Markdown syntax] not supported?
Pelican doesn't directly handle Markdown processing β it delegates that task to the Python-Markdown <https://github.com/Python-Markdown/markdown> project, the core of which purposefully follows the original Markdown syntax rules and not the myriad Markdown "flavors" that have subsequently propagated. That said, Python-Markdown <https://github.com/Python-Markdown/markdown> is quite modular, and the syntax you're looking for may be provided by one of the many available Markdown Extensions <https://python-markdown.github.io/extensions/>. Alternatively, some folks have created Pelican plugins that support Markdown variants, so that may be your best choice if there's a particular variant you want to use when writing your content. Go find your flavor, bestie π
β¨ TIPS β¨
Here are some tips about Pelican that you might find useful π
π Custom 404 Pages
When a browser requests a resource that the web server can't find, the web 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 of your site is to create a custom 404 page (not an article), such as this Markdown-formatted example stored in content/pages/404.md:
Title: Not Found
Status: hidden
Save_as: 404.html
The requested item could not be located. Perhaps you might want to check
the [Archives](/archives.html)?
Aesthetically consistent error pages? Obsessed, honestly π
For Nginx, just drop this into your config file's location block:
error_page 404 /404.html;
Apache bestie? You're getting this instead:
ErrorDocument 404 /404.html
And for Amazon S3, first go find the Static Site Hosting menu in the bucket settings on your AWS console. Once you're in there:
Error Document: 404.html
π¦ Publishing to GitHub Pages
Okay so if you use GitHub for your Pelican site, you can publish it to GitHub Pages for free β literally no money, none. β¨ Your site goes live at https://<username>.github.io if it's a user or organization site, or at https://<username>.github.io/<repository> if it's a project site. And yes, a custom domain works too β you can set that up with GitHub Pages as well (docs at https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site).
There are two ways to publish a site to GitHub Pages (ref: https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site):
- Publishing from a branch β you run
pelicanlocally and push theoutputdirectory to a special branch of your GitHub repo. GitHub then publishes the contents of that branch to your GitHub Pages site. Iconic, classic, works every time. - Publishing with a custom GitHub Actions workflow β you just push the source files of your Pelican site to your GitHub repo's default branch and let a custom GitHub Actions workflow run
pelicanfor you, generating the output directory and publishing it to your GitHub Pages site. The way this one means you don't even need to runpelicanlocally?? Yeah. You can legit edit your site's source files straight through GitHub's web interface and any changes you commit get published. main character workflow fr π
π Publishing a Project Site to GitHub Pages from a Branch
To publish a Pelican site as a Project Page, you need to push the content of the output dir generated by Pelican to a repository's gh-pages branch on GitHub.
The excellent ghp-import (find it at https://github.com/davisp/ghp-import) β which installs with pip btw β makes this whole process honestly so easy it's unfair.
So like, if the source of your Pelican site lives in a GitHub repository, and you want to publish that Pelican site as Project Pages to that same repository, you can just do:
$ pelican content -o output -s pelicanconf.py
$ ghp-import output -b gh-pages
$ git push origin gh-pages
The ghp-import output command updates the local gh-pages branch with the content of the output directory (it'll create that branch if it doesn't already exist, no stress). Then git push origin gh-pages updates the remote gh-pages branch, and congrats bestie β that's your Pelican site published. π
Note: thegithubtarget of theMakefile(and thegh_pagestask oftasks.py) that thepelican-quickstartcommand creates publishes the Pelican site as Project Pages, exactly as described above. So it's kind of already handled for you.
πΈ Publishing a User Site to GitHub Pages from a Branch
Want your Pelican site as User Pages? Then you need to push the content of the output dir generated by Pelican to the main branch of your <username>.github.io repository on GitHub.
Again, ghp-import is right there for you:
$ pelican content -o output -s pelicanconf.py
$ ghp-import output -b gh-pages
$ git push git@github.com:elemoine/elemoine.github.io.git gh-pages:main
That git push command pushes the local gh-pages branch (freshly updated by the ghp-import command, literally seconds ago) to the elemoine.github.io repository's main branch on GitHub.
Note: if you want to publish your Pelican site as User Pages, feel free to adjust thegithubtarget of theMakefile. It's your world.
Another option for publishing to User Pages is to generate the output files in the root directory of the project.
So like, say your main project folder is <username>.github.io and you create the Pelican project in a subdirectory called Pelican. Then from inside the Pelican folder you can run:
$ pelican content -o .. -s pelicanconf.py
Now you can push the whole project <username>.github.io to the main branch of your GitHub repository:
$ git push origin main
(assuming origin is set to your remote repository, obviously π).
β Publishing to GitHub Pages Using a Custom GitHub Actions Workflow
Pelican-powered sites can be published to GitHub Pages via a custom workflow, and the official one lives here: https://github.com/getpelican/pelican/blob/main/.github/workflows/github_pages.yml. To use it:
- Enable GitHub Pages in your repo: go to Settings β Pages and choose GitHub Actions for the Source setting.
- Commit a
.github/workflows/pelican.ymlfile to your repo with these contents:
name: Deploy to GitHub Pages
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
deploy:
uses: "getpelican/pelican/.github/workflows/github_pages.yml@main"
permissions:
contents: "read"
pages: "write"
id-token: "write"
with:
settings: "publishconf.py"
You may want to replace the @main with the ID of a specific commit in this repo in order to pin the version of the reusable workflow that you're using: uses: getpelican/pelican/.github/workflows/github_pages.yml@<COMMIT_ID>. And if you do that, you might want to get Dependabot to send you automated pull requests to update that commit ID whenever new versions of this workflow are published, like so:
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
See GitHub's docs about using Dependabot to keep your actions up to date: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot.
- Go to the Actions tab in your repo (
https://github.com/<username>/<repository>/actions) and you should see aDeploy to GitHub Pagesaction running. π - Once the action completes you should see your Pelican site deployed at your repo's GitHub Pages URL:
https://<username>.github.iofor a user or organization site, orhttps://<username>.github.io/<repository>>for a project site.
Notes:
- You don't need to set
SITEURLorFEED_DOMAINin your Pelican settings: the workflow will set them correctly for you. π«Ά - You don't need to commit your
--output/OUTPUT_PATHdirectory (output/) to git: the workflow will runpelicanto build the output directory for you on GitHub Actions.
See GitHub's docs about reusable workflows (https://docs.github.com/en/actions/using-workflows/reusing-workflows) for more information.
A number of optional inputs can be added to the with: block when calling the workflow, for example:
with:
settings: "publishconf.py"
requirements: "pelican[markdown] typogrify"
theme: "https://github.com/seanh/sidecar.git"
python: "3.12"
Here's the complete list of workflow inputs:
settingsβ Required: Yes. Type:string. Default: (none). The path to your Pelican settings file (pelican's--settingsoption), for example:"publishconf.py".requirementsβ Required: No. Type:string. Default:"pelican". The Python requirements to install, for example to enable markdown and typogrify use:"pelican[markdown] typogrify"β or if you have a requirements file:"-r requirements.txt".output-pathβ Required: No. Where to output the generated files (pelican's--outputoption).themeβ No Β·stringΒ· default""β the GitHub repo URL of a custom theme you wanna use, like for real for example:"https://github.com/seanh/sidecar.git"πtheme-checkoutβ No Β·stringΒ· default""β the Git ref (branch, tag or commit) of the theme repo to checkout. This is the lil' pin so you can lock down the version of your theme. If you don't specify it, it just defaults to the theme repo's default branch. no cap β¨pythonβ No Β·stringΒ· default"3.12"β the version of Python used to build the site, for example:"3.12"(to use the most recent version of Python 3.12 β this is faster) or"3.12.1"(to use an exact version β slower) πsiteurlβ No Β·stringΒ· default: the URL of your GitHub Pages site β the base URL of your web site (Pelican'sSITEURLsetting). If you don't pass it, it defaults to the URL of your GitHub Pages site, which is correct in most cases. slay π«Άfeed_domainβ No Β·stringΒ· default: the URL of your GitHub Pages site β the domain to be prepended to feed URLs (Pelican'sFEED_DOMAINsetting). If you don't pass it, it defaults to the URL of your GitHub Pages site, which is correct in most cases. iconically correct πdeployβ No Β·boolΒ· defaulttrueβ this is the one that decides whether you will deploy the site or not to GitHub Pages. It's most useful if you want to test a change to your website in a pull request before deploying those changes. main character behavior honestly πstorkβ No Β·boolΒ· defaultfalseβ this decides whether Stork will be installed on the runner so you can build a site with Stork search enabled π
π§ͺ Testing Your Build in a GitHub Pull Request
Okay so if you wanna test your build in a pull request before deploying to GitHub, your workflow might look something like this, bestie:
name: Build and Deploy Site
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
inputs:
deploy:
required: false
default: true
description: "Whether to deploy the site. If checked, then build the site and deploy it. If not checked, then just test that the site builds successfully but don't deploy anything."
type: boolean
jobs:
deploy:
uses: "getpelican/pelican/.github/workflows/github_pages.yml@main"
permissions:
id-token: write
contents: read
pages: write
with:
settings: "publishconf.py"
requirements: "-r requirements.txt"
deploy: ${{ (github.event_name == 'workflow_dispatch' && inputs.deploy == true) || (github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch) }}
The on section of the workflow is literally the vibe check for what triggers the workflow. In this example, the workflow will run on pushes to the main branch, pull requests to the main branch, and manual runs of the workflow. β¨
workflow_dispatch defines the deploy boolean to be true by default. Which means if you run the workflow manually, it will deploy the site. π
The deploy input for the job is using a set of standard GitHub workflow variables to control when deploy will either be true or false (you can customize this to your needs, bestie β it's giving customizable).
So in this example, the deploy will be true if the event is a push to the main branch (or merging into main from a PR) or a manual run of the workflow. If the event is a pull request, the deploy will be false and it will only build an artifact for the site. no deploy, just vibes π¦
β οΈ "Insecure content" warnings from browsers
If your site uses https:// and is broken because the browser is blocking network requests (for example for CSS files) due to "insecure content" β that may be because GitHub Pages is generating http:// URLs for your site. π
To fix this, go into your site repo's settings and enable the Enforce HTTPS setting: go to Settings β Pages and check Enforce HTTPS. Then re-run the workflow to re-deploy your site. Alternatively, you can use the workflow's siteurl and feed_domain settings. easy fix, periodt π
π« Custom 404 Pages
GitHub Pages will display the custom 404 page described above, as noted in the relevant GitHub docs https://help.github.com/articles/custom-404-pages/. π
π Update your site on each commit
To automatically update your Pelican site on each commit, you can create a post-commit hook. For example, you can add the following to .git/hooks/post-commit:
pelican content -o output -s pelicanconf.py && ghp-import output && git push origin gh-pages
lowkey magic, highkey useful π₯
π Copy static files to the root of your site
To use a custom domain https://help.github.com/articles/setting-up-a-custom-domain-with-pages with GitHub Pages, you need to put the domain of your site (e.g., blog.example.com) inside a CNAME file at the root of your site. To do this, create the content/extra/ directory and add a CNAME file to it. Then use the STATIC_PATHS setting to tell Pelican to copy this file to your output directory. For example:
STATIC_PATHS = ['images', 'extra/CNAME']
EXTRA_PATH_METADATA = {'extra/CNAME': {'path': 'CNAME'},}
Note: use forward slashes, /, even on Windows. π
You can also use the EXTRA_PATH_METADATA mechanism to place a favicon.ico or robots.txt at the root of any site. cute and handy fr fr πΈ
πΊ How to add YouTube or Vimeo Videos
The easiest way is to paste the embed code of the video from these sites directly into your source content. π
Alternatively, you can also use Pelican plugins like liquid_tags, pelican_youtube, or pelican_vimeo to embed videos in your content.
Moreover, markup languages like reST and Markdown have plugins that let you embed videos in the markup. You can use reST video directive https://gist.github.com/dbrgn/2922648 for reST or mdx_video plugin https://github.com/italomaia/mdx-video for Markdown. so many options, we love choices π
π Develop Locally Using SSL
Here's how you can set up your local pelican server to support SSL.
First, create a self-signed certificate and key using openssl (this creates cert.pem and key.pem):
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
And use this command to launch the server (the server starts within your output directory):
python -m pelican.server 8443 --key=../key.pem --cert=../cert.pem
If you are using develop-server.sh, add this to the top:
CERT="$BASEDIR/cert.pem"
KEY="$BASEDIR/key.pem"
and modify the pelican.server line as follows:
$PY -m pelican.server $port --ssl --cert="$CERT" --key="$KEY" &
secure local dev era, obsessed π§
π¬ Contributing and feedback guidelines
There are so many ways to contribute to Pelican. You can improve the documentation, add missing features, and fix bugs (or just report them). You can also help out by reviewing and commenting on existing issues: https://github.com/getpelican/pelican/issues. π«Ά
Don't hesitate to fork Pelican and submit an issue or pull request on GitHub. When doing so, please consider the following guidelines. π
π Filing issues
- Before you submit a new issue, try asking for help first. π₯Ί
- π¬ If you're dead set on creating a new issue, first go search Pelican Discussions <https://github.com/getpelican/pelican/discussions> and the existing issues <https://github.com/getpelican/pelican/issues> β both open and closed, bestie β to see if your question has already been answered before. No cap, someone probably asked it already.
π«Ά How to get help π«Ά
Before you come ask for help, please please please do these things first:
- Read the documentation <https://docs.getpelican.com/> thoroughly. Like, actually. If you're in a rush, at least use the search field chilling at the top-left of the documentation <https://docs.getpelican.com/> pages. And make sure you're reading the docs for the Pelican version you're actually using β not some random other version, iykyk.
- Use a search engine (e.g., DuckDuckGo, Google) to search for a solution to your problem. Someone may have already found a solution, perhaps in the form of a 'plugins <https://docs.getpelican.com/en/latest/plugins.html> or a specific combination of settings. The internet is literally right there π
- Try reproducing the issue in a clean environment, ensuring you are using:
- latest Pelican release (or an up-to-date Git clone of Pelican main branch)
- latest releases of libraries used by Pelican
- no plugins or only those related to the issue
NOTE: The most common sources of problems are anomalies in (1) themes, (2) plugins, (3) settings files, and (4) make/invoke automation wrappers. If you can't reproduce your problem when using the following steps to generate your site, then the problem is almost certainly with one of the above-listed elements (and not Pelican itself):
cd ~/projects/your-site
git clone https://github.com/getpelican/pelican ~/projects/pelican
pelican content -s ~/projects/pelican/samples/pelican.conf.py -t ~/projects/pelican/pelican/themes/notmyidea
If you can generate your site without problems using the steps above, then your problem is unlikely to be caused by Pelican itself, and therefore please consider reaching out to the maintainers of the plugins/theme you are using instead of raising the topic with the Pelican core community. Respectfully, they're the ones who know their stuff π«Ά
If despite the above efforts you still cannot resolve your problem, be sure to include in your inquiry the following information, preferably in the form of links to content uploaded to a paste service <https://dpaste.com>, GitHub repository, or other publicly-accessible location:
- Describe what version of Pelican you are running (output of
pelican --versionor the HEAD commit hash if you cloned the repo) and how exactly you installed it (the full command you used, e.g.python -m pip install pelican). Receipts, bestie β¨ - If you are looking for a way to get some end result, prepare a detailed description of what the end result should look like (preferably in the form of an image or a mock-up page) and explain in detail what you have done so far to achieve it. Show us the vision π
- If you are trying to solve some issue, prepare a detailed description of how to reproduce the problem. If the issue cannot be easily reproduced, it cannot be debugged by developers or volunteers. Describe only the minimum steps necessary to reproduce it (no extra plugins, etc.). Keep it minimal, keep it clean π§
- Upload your settings file or any other custom code that would enable people to reproduce the problem or to see what you have already tried to achieve the desired end result.
- Upload detailed and complete output logs and backtraces (remember to add the
--debugflag:pelican --debug content [...])
Once the above preparation is ready, you can post your query as a new thread in Pelican Discussions <https://github.com/getpelican/pelican/discussions>. Remember to include all the information you prepared. You got this πͺ
π Contributing code π
Before you submit a contribution, please ask whether it is desired so that you don't spend a lot of time working on something that would be rejected for a known reason. Lowkey heartbreaking to pour your soul into a PR just for it to get closed π Consider also whether your new feature might be better suited as a 'plugins <https://docs.getpelican.com/en/latest/plugins.html> β you can ask for help to make that determination.
Also, if you intend to submit a pull request to address something for which there is no existing issue, there is no need to create a new issue and then immediately submit a pull request that closes it. You can submit the pull request by itself. Skip the extra steps, main character energy only π
π¦ Using Git and GitHub π¦
- Create a new branch <https://github.com/getpelican/pelican/wiki/Git-Tips#making-your-changes> specific to your change (as opposed to making your commits in the main branch). Keep your main branch pristine, periodt.
- Don't put multiple unrelated fixes/features in the same branch / pull request. For example, if you're working on a new feature and find a bugfix that doesn't require your new feature, make a new distinct branch and pull request for the bugfix. Similarly, any proposed changes to code style formatting should be in a completely separate pull request. One vibe per PR, fr fr.
- Add a
RELEASE.mdfile in the root of the project that contains the release type (major, minor, patch) and a summary of the changes that will be used as the release changelog entry. For example:
Release type: minor
Reload browser window upon changes to content, settings, or theme
- Check for unnecessary whitespace via
git diff --checkbefore committing. - First line of your commit message should start with present-tense verb, be 50 characters or less, and include the relevant issue number(s) if applicable. Example:
Ensure proper PLUGIN_PATH behavior. Refs #428.If the commit completely fixes an existing bug report, please useFixes #585orFix #585syntax (so the relevant issue is automatically closed upon PR merge). - After the first line of the commit message, add a blank line and then a more detailed explanation (when relevant). Give us the lore π
- Squash your commits <https://github.com/getpelican/pelican/wiki/Git-Tips#squashing-commits> to eliminate merge commits and ensure a clean and readable commit history. Nobody wants a messy history, it's giving chaos π
- After you have issued a pull request, the continuous integration (CI) system will run the test suite on all supported Python versions and check for code style compliance. If any of these checks fail, you should fix them. (If tests fail on the CI system but seem to pass locally, ensure that local test runs aren't skipping any tests.) The CI is watching you π
π Contribution quality standards π
- Adhere to the project's code style standards. See: Development Environment <https://docs.getpelican.com/en/latest/contribute.html#setting-up-the-development-environment>
- Ensure your code is compatible with the officially-supported Python releases <https://devguide.python.org/versions/#versions>.
- Add docs and tests for your changes. Undocumented and untested features will not be accepted. No tests = no entry, sorry bestie π
- Run all the tests <https://docs.getpelican.com/en/latest/contribute.html> on all versions of Python supported by Pelican to ensure nothing was accidentally broken. Don't let a sneaky regression in, ngl.
Check out our Git Tips <https://github.com/getpelican/pelican/wiki/Git-Tips> page or ask for help if you need assistance or have any questions about these guidelines. We're nice, promise π«Ά
β¨ Setting up the development environment β¨
While there are many ways to set up one's development environment, the following instructions will utilize Pip <https://pip.pypa.io/> and PDM <https://pdm.fming.dev/latest/>. These tools facilitate managing virtual environments for separate Python projects that are isolated from one another, so you can use different packages (and package versions) for each. It's like having separate little rooms for each project, so they can't bother each other π
Please note that Python >=3.11 is required for Pelican development. Like, mandatory π
(Optional) If you prefer to install PDM <https://pdm.fming.dev/latest/#installation> once for use with multiple projects, you can install it via:
curl -sSL https://pdm.fming.dev/install-pdm.py | python3 -
Point your web browser to the Pelican repository <https://github.com/getpelican/pelican> and tap the Fork button at top-right. Then clone the source for your fork and add the upstream project as a Git remote:
mkdir ~/projects
git clone https://github.com/YOUR_USERNAME/pelican.git ~/projects/pelican
cd ~/projects/pelican
git remote add upstream https://github.com/getpelican/pelican.git
While PDM can dynamically create and manage virtual environments, we're going to manually create and activate a virtual environment:
mkdir ~/virtualenvs && cd ~/virtualenvs
python3 -m venv pelican
source ~/virtualenvs/pelican/*/activate
Install the needed dependencies and set up the project:
python -m pip install invoke
invoke setup
Your local environment should now be ready to go! Slay π
π₯ Development π₯
Once Pelican has been set up for local development, create a topic branch for your bug fix or feature:
git checkout -b name-of-your-bugfix-or-feature
Now you can make changes to Pelican, its documentation, and/or other aspects of the project. Go off π
π§ Setting up git blame (optional) π§
git blame annotates lines in a file with information about the pull request that last modified it. Sweeping shallow changes (like formatting) can make that information less useful, so we keep a list of such changes to be ignored. Run the following command to set this up in your repository, adding --global if you want this setting to apply to all repositories:
git config blame.ignoreRevsFile .git-blame-ignore-revs
As noted in a useful article <https://www.michaelheap.com/git-ignore-rev/> about git blame, there are other related settings you may find to be beneficial:
# Add `?` to any lines that have had a commit skipped using --ignore-rev
git config --global blame.markIgnoredLines true
# Add `*` to any lines that were added in a skipped commit and can not be attributed
git config --global blame.markUnblamableLines true
πΈ Running the test suite πΈ
Each time you make changes to Pelican, there are two things to do regarding tests: check that the existing tests pass, and add tests for any new features or bug fixes. The tests are located in pelican/tests, and you can run them via:
invoke tests
(For more on Invoke, see invoke -l to list tasks, or <https://pyinvoke.org> for documentation.) Very demure, very mindful π
In addition to running the test suite, it is important to also ensure that any lines you changed conform to code style guidelines. You can check that via:
invoke lint
If style violations are found, many of them can be addressed automatically via:
invoke lint --fix
invoke format
If code style violations are found in lines you changed, correct those lines and re-run the invoke lint command until they have all been fixed. You do not need to address style violations, if any, for code lines you did not touch. Not your lines, not your problem, bestie π
After you've made your changes and run the tests, you might see a failure that goes something like "some generated files differ from the expected functional tests output." π± Before you panic β breathe. If your changes affect the HTML output Pelican generates, and those output changes are expected and genuinely correct given what you changed, then you should update the output the functional tests compare against. To do that, first make sure you have both the en_EN.utf8 and fr_FR.utf8 locales installed, and then run:
invoke update-functional-tests
You might also notice some tests getting skipped because a dependency (like Pandoc) isn't installed. Ngl bestie, a skip is not a pass β you should at least verify that any skipped tests aren't affected by your changes. π«Ά
You should run the test suite under each of the supported versions of Python. The best way to do that is to create a separate Python environment for each version. Tox (https://tox.readthedocs.io/en/latest/) is a handy tool for automating test runs inside virtualenv environments. β¨
π Running a code coverage report
Code stays way more robust when it's actually tested β periodt. Coverage (https://github.com/nedbat/coveragepy) is a library that measures how much of your code is covered by tests. To run it:
invoke coverage
This shows you overall coverage, coverage per file, and even line-by-line coverage. There's also an HTML report available:
open htmlcov/index.html
π¦ Building the docs
If you touch the documentation, build it and inspect your changes before committing them:
invoke docserve
Open http://localhost:8000 in your browser to review the docs. While that task is running, any changes you make and save to the documentation should automatically show up in the browser β it live-reloads when it detects changes to the documentation source files. So slay, basically. π
πΈ Plugin development
Want to create a brand-new Pelican plugin? Please refer to the plugin template repository at https://github.com/getpelican/cookiecutter-pelican-plugin for the detailed instructions. π
If you want to contribute to an existing Pelican plugin instead, follow the steps above to set up Pelican for local development, and then create a directory to store your cloned plugin repos:
mkdir -p ~/projects/pelican-plugins
Say you wanted to contribute to the Simple Footnotes plugin β you'd first browse to the Simple Footnotes repository at https://github.com/pelican-plugins/simple-footnotes on GitHub and tap that Fork button at the top-right. Then clone the source for your fork and add the upstream project as a Git remote:
git clone https://github.com/YOUR_USERNAME/simple-footnotes.git ~/projects/pelican-plugins/simple-footnotes
cd ~/projects/pelican-plugins/simple-footnotes
git remote add upstream https://github.com/pelican-plugins/simple-footnotes.git
Install the needed dependencies and set up the project:
invoke setup
Create a topic branch for your plugin bug fix or feature:
git checkout -b name-of-your-bugfix-or-feature
After writing new tests for your plugin changes, run the plugin test suite and check for code style compliance via:
invoke tests
invoke lint
If style violations turn up, a lot of them can be fixed automatically via:
invoke lint --fix
invoke format
And if style violations are still hanging around even after running those auto-formatters, you'll have to make additional manual changes until invoke lint stops reporting any code style violations. π
π Submitting your changes
Assuming the linting validation and the tests pass, add a RELEASE.md file in the root of the project containing the release type (major, minor, patch) plus a summary of the changes β that summary gets used as the release changelog entry. For example:
Release type: patch
Fix browser reloading upon changes to content, settings, or theme
Commit your changes and push your topic branch:
git add .
git commit -m "Your detailed description of your changes"
git push origin name-of-your-bugfix-or-feature
Finally, browse to your repository fork on GitHub and submit a pull request. Main character energy, honestly. π
π Logging tips
Try to use logging with appropriate levels, okay?
For logging messages that aren't repeated, use the usual Python way:
# at top of file
import logging
logger = logging.getLogger(__name__)
# when needed
logger.warning("A warning with %s formatting", arg_to_be_formatted)
Do not format log messages yourself. Use %s formatting in messages and pass arguments to logger. This matters because the Pelican logger preprocesses some arguments, such as exceptions. π₯
β Limiting extraneous log messages
If a log message can occur several times, you might want to limit it so it doesn't flood everything. To do that, use the extra keyword argument for the logging message in this format:
logger.warning("A warning with %s formatting", arg_to_be_formatted,
extra={'limit_msg': 'A generic message for too many warnings'})
Optionally, you can also set 'limit_args' as a tuple of arguments in the extra dict if your generic message needs formatting.
The limit is set to 5 β that is, the first four logs with the same 'limit_msg' are outputted normally, but the fifth one gets logged using 'limit_msg' (and 'limit_args' if present). After the fifth, the corresponding log messages are ignored. π
For example, if you want to log missing resources, use this code:
for resource in resources:
if resource.is_missing:
logger.warning(
'The resource %s is missing', resource.name,
extra={'limit_msg': 'Other resources were missing'})
The log messages will be displayed like this:
WARNING: The resource prettiest_cat.jpg is missing
WARNING: The resource best_cat_ever.jpg is missing
WARNING: The resource cutest_cat.jpg is missing
WARNING: The resource lolcat.jpg is missing
WARNING: Other resources were missing
π§ Outputting traceback in the logs
If you're logging inside an except block, you may want to include the traceback info too. You can do that by setting the exc_info keyword argument to True while logging. But doing that by default can be undesired, because tracebacks are long and can be confusing to regular users. Try to limit them to --debug mode, like this:
try:
some_action()
except Exception as e:
logger.error('Exception occurred: %s', e,
exc_info=settings.get('DEBUG', False))
π¦ Pelican internals
This section describes how Pelican works internally. As you'll see, it's quite simple β but a bit of documentation doesn't hurt. :)
You can also find, in the Some history about Pelican section, an excerpt of a report the original author wrote with some software design information.
πΈ Overall structure
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 files, and the output is a blog β but honestly, both input and output can be anything you want.
The logic is separated into different classes and concepts:
- Writers are responsible for writing files:
.htmlfiles, RSS feeds, and so on. Since those operations are commonly used, the object is created once and then passed to the generators. - Readers are used to read from various formats (HTML, Markdown and reStructuredText for now, but the system is extensible). Given a file, they return metadata (author, tags, category, etc.) and content (HTML-formatted).
- Generators generate the different outputs. For instance, Pelican comes with
ArticlesGeneratorandPageGenerator. Given a configuration, they 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 syntax is Jinja2 (
https://palletsprojects.com/p/jinja/) and it's very easy to learn, so don't hesitate to jump in and build your own theme. π
β¨ How to implement a new reader?
Is there an awesome markup language you want to add to Pelican? Well, the only thing you have to do is create a class with a read method that returns HTML content and some metadata.
Take a look at the Markdown reader:
from pelican.readers import BaseReader
from pelican.utils import pelican_open
from markdown import Markdown
class MarkdownReader(BaseReader):
enabled = True
def read(self, source_path):
"""Parse content and metadata of markdown files"""
with pelican_open(source_path) as text:
md_extensions = {'markdown.extensions.meta': {},
'markdown.extensions.codehilite': {}}
md = Markdown(extensions=md_extensions.keys(),
extension_configs=md_extensions)
content = md.convert(text)
metadata = {}
for name, value in md.Meta.items():
name = name.lower()
meta = self.process_metadata(name, value[0])
metadata[name] = meta
return content, metadata
Simple, isn't it? π
If your new reader needs additional Python dependencies, then you should wrap their import statements in a try...except block. Then, inside the reader's class, set the enabled class attribute to mark import success or failure. This makes it possible for users to keep using their favourite markup method without needing to install modules for formats they don't use. π«Ά
π How to implement a new generator?
Generators have two important methods. You're not forced to create both β only the existing ones will be called.
generate_context, which is called first, for all the generators. Do whatever you have to do, and update the global context if needed. This context is shared between all generators, and will be passed to the templates. For instance, thePageGeneratorgenerate_contextmethod finds all the pages, transforms them into objects, and populates the context with them. Be careful not to output anything using this context at this stage, because it's likely to change thanks to the effect of other generators.generate_outputis then called. And guess what it's made for? Oh, generating the output. :) It's here that you may want to look at the context and call the methods of thewriterobject that's passed as the first argument of this function. In thePageGeneratorexample, this method will look at all the pages recorded in the global context and output a file on the disk (using the writer methodwrite_file) for each page encountered. β
π Some history about Pelican π
β οΈ Warning: this page comes from a report the original author (Alexis MΓ©taireau) wrote right after writing Pelican, back in December 2010. The info may not be up-to-date. π
Pelican is a simple static blog generator, and honestly? iconic behavior. It parses markup files (Markdown or reStructuredText for now) and generates an HTML folder with all the files in it. So the author chose to use Python to implement Pelican because it seemed simple and fit their needs β they did not want to define a class for each thing, but still wanted everything loosely coupled, and it turns out that was exactly the vibe they wanted. From time to time, thanks to feedback from some users, it took very little time to ship fixes. At the time of writing, the Pelican code had been re-factored twice, and each time took less than 30 minutes. slay.
π οΈ Use case
Previously the author was using WordPress β a solution you can host on a web server to manage your blog. Most of the time, they prefer using markup languages such as Markdown or reStructuredText to type articles, and to do that they use vim. And honestly, it's important to let people choose the tool they want to write articles in. In their opinion, a blog manager should just let you take any kind of input and transform it into a weblog. That's literally what Pelican does π You can write your articles using the tool you want, and the markup language you want, and then generate a static HTML weblog. [image]
To be flexible enough, Pelican has template support, so you can easily write your own themes if you want to. π
π§ Design process
Pelican came from a need the author had. They started by creating a single file application, then made it grow to support what it does now. To start, they wrote a piece of documentation about what they wanted to do. Then they created the content they wanted to parse (the reStructuredText files) and started experimenting with the code. Pelican was 200 lines long and contained almost ten functions and one class when it was first usable. π¦
They faced different problems all over the time and wanted to add features to Pelican while using it. The first change made was adding support for a settings file β you can pass the options on the command line, but that gets tedious when there's a lot of them. Same energy with everything else added over time: Atom feeds, multiple themes, multiple markup support, etc. At some point it turned out that the "only one file" mantra was not good enough for Pelican, so they decided to rework a bit of all that and split it into multiple different files.
The logic got separated into different classes and concepts:
- writers are responsible for all the writing process of the files. They're responsible for writing
.htmlfiles, RSS feeds and so on. Since those operations are commonly used, the object is created once, and then passed to the generators. - readers are used to read from various formats (Markdown and reStructuredText for now, but the system is extensible). Given a file, they return metadata (author, tags, category, etc) and content (HTML formatted).
- generators generate the different outputs. For instance, Pelican comes with an
ArticlesGeneratorandPagesGenerator, into others. Given a configuration, they can do whatever you want them to do. Most of the time it's generating files from inputs (user inputs and files).
There are also contents objects in the mix π«Ά They can be Articles, Pages, Quotes, or whatever you want. They're defined in the contents.py module and represent some content to be used by the program.
π In more detail
Here's an overview of the classes involved in Pelican. [image]
The interface does not really exist, and it was only added to clarify the whole picture. The author uses duck typing and not interfaces β no cap. π¦
Internally, the following process is followed:
- First of all, the command line is parsed, and some content from the user is used to initialize the different generator objects.
- A context is created. It contains the settings from the command line and a settings file if provided.
- The
generate_contextmethod of each generator is called, updating the context. - The writer is created and given to the
generate_outputmethod of each generator.
Two calls happen because it's important that when the output is 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's up to the generators to do what they want, in the generate_context and generate_content method. Taking the ArticlesGenerator class helps to understand some other concepts. Here's what happens when calling the generate_context method:
- Read the folder "
path", looking for restructured text files, load each of them, and construct a content object (Article) with it. To do so, useReaderobjects. - Update the context with all those articles.
Then, the generate_content method uses the context and the writer to generate the wanted output. π
ποΈ Release history
4.12.0 - 2026-04-20
- Add dark mode to notmyidea template (
#3490) βhttps://github.com/getpelican/pelican/pull/3490 - Support
CSS_FILEsetting in Simple theme (#3555) βhttps://github.com/getpelican/pelican/pull/3555 - Improve Simple theme template inheritance (
#3570) βhttps://github.com/getpelican/pelican/pull/3570 - Strip table-of-contents elements from article summaries (
#3512) βhttps://github.com/getpelican/pelican/pull/3512 - Use slug in category/tag feed titles (
#3569) βhttps://github.com/getpelican/pelican/pull/3569 - Fix raising exceptions on filtered logs (
#3547) βhttps://github.com/getpelican/pelican/pull/3547 - Fix disabled category output (
#3589) βhttps://github.com/getpelican/pelican/pull/3589 - Fix default
FEED_DOMAINto fall back toSITEURL(#3477) βhttps://github.com/getpelican/pelican/pull/3477 - Don't log feed warning if
FEED_DOMAINis set (#3544) βhttps://github.com/getpelican/pelican/pull/3544 - Fix livereload import in
docserve()task (#3583) βhttps://github.com/getpelican/pelican/pull/3583 - Fix JavaScript MIME detection on Windows (
#3594) βhttps://github.com/getpelican/pelican/pull/3594 - Fix linking to individual settings in docs (
#3458) βhttps://github.com/getpelican/pelican/pull/3458 - Overhaul installation instructions; add
pipxanduv(#3549) βhttps://github.com/getpelican/pelican/pull/3549 - Enhance GitHub Pages workflow (
#3452) βhttps://github.com/getpelican/pelican/pull/3452& (#3529) βhttps://github.com/getpelican/pelican/pull/3529 - Require Docutils
0.22+and Sphinx9.0+(#3579) βhttps://github.com/getpelican/pelican/pull/3579 - Require Python
3.11and above; add Python3.14to test matrix (#3514) βhttps://github.com/getpelican/pelican/pull/3514
4.11.0 - 2025-01-15
- Add setting to selectively omit Typogrify filters (
#3439) βhttps://github.com/getpelican/pelican/pull/3439 - Add more blocks to the Simple theme's base template, making it easier to create new themes by inheriting from the Simple theme (
#3405) βhttps://github.com/getpelican/pelican/pull/3405 - Fix auto-reload behavior upon changes to the theme, content or settings. Make default
IGNORE_FILESrecursively ignore all hidden files as well as the default filtershttps://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_dirsfromwatchfiles.DefaultFilter. (#3441) βhttps://github.com/getpelican/pelican/pull/3441 - Get current year from the
SOURCE_DATE_EPOCHenvironment variable, if available (#3430) βhttps://github.com/getpelican/pelican/pull/3430 - Add Python
3.13to test matrix and remove Python3.8(#3435) βhttps://github.com/getpelican/pelican/pull/3435 - Require Typogrify
2.1+and Pygments<2.19
4.10.2 - 2024-11-27
- Change
IGNORE_FILESsetting default to ignore all hidden files - Fix
SUMMARY_MAX_PARAGRAPHSnot being respected in some combinations withSUMMARY_MAX_LENGTH
4.10.1 - 2024-09-28
- Fix error when running
pelican -r -l - Fix symlink handling in
pelican-themes
4.10.0 - 2024-09-16
- Add setting to specify summary via paragraph count
- Add new status to skip generation of a post
- Add setting to append ref parameter to links in feeds
- Configure logging handler via
--log-handlerCLI option - Resolve intra-site links in summaries
- Warn when files are not processed due to disabled readers
- Add Medium post importer
- Improve GitHub Pages workflow
- Improve code test coverage
- Translate documentation into Simplified Chinese
4.9.1 - 2023-11-15
- Ensure
tzdatadependency is installed on Windows
4.9.0 - 2023-11-12
- Upgrade code to new minimum supported Python version:
3.8 - Settings support for
pathlib.Path(#2758) βhttps://github.com/getpelican/pelican/pull/2758 - Various improvements to Simple theme (
#2976βhttps://github.com/getpelican/pelican/pull/2976ಢβhttps://github.com/getpelican/pelican/pull/3234) - Use Furo as Sphinx documentation theme (
#3023) βhttps://github.com/getpelican/pelican/pull/3023 - Default to 100 articles maximum in feeds (
#3127) βhttps://github.com/getpelican/pelican/pull/3127 - Add
period_archivescommon context variable (#3148) βhttps://github.com/getpelican/pelican/pull/3148 - Use
watchfilesas the file-watching backend (#3151) βhttps://github.com/getpelican/pelican/pull/3151 - Add GitHub Actions workflow for GitHub Pages (
#3189) βhttps://github.com/getpelican/pelican/pull/3189 - Allow dataclasses in settings (
#3204) βhttps://github.com/getpelican/pelican/pull/3204 - Switch build tool to PDM instead of Setuptools/Poetry (
#3220) βhttps://github.com/getpelican/pelican/pull/3220 - Provide a
plugin_enabledJinja test for themes (#3235) βhttps://github.com/getpelican/pelican/pull/3235 - Preserve connection order in Blinker (
#3238) βhttps://github.com/getpelican/pelican/pull/3238 - Remove social icons from default notmyidea theme (
#3240) βhttps://github.com/getpelican/pelican/pull/3240 - Remove unreliable
WRITE_SELECTEDfeature (#3243) βhttps://github.com/getpelican/pelican/pull/3243 - Importer: Report broken embedded video links when importing from Tumblr (
#3177) βhttps://github.com/getpelican/pelican/issues/3177 - Importer: Remove newline addition when iterating Photo post types (
#3178) βhttps://github.com/getpelican/pelican/issues/3178 - Importer: force timestamp conversion in the Tumblr importer to be UTC with offset (#3221) <https://github.com/getpelican/pelican/pull/3221>
- Importer: use
tempfilefor the intermediate HTML file for Pandoc (#3221) <https://github.com/getpelican/pelican/pull/3221> - Switch linters to Ruff (#3223) <https://github.com/getpelican/pelican/pull/3223>
π 4.8.0 - 2022-07-11
- Use JSON values for extra settings in the Invoke tasks template (#2994) <https://github.com/getpelican/pelican/pull/2994>
- Add a content tag for links, which can help with things like Twitter social cards (#3001) <https://github.com/getpelican/pelican/pull/3001>
- Improve word count behavior when generating a summary (#3002) <https://github.com/getpelican/pelican/pull/3002>
π¦ 4.7.2 - 2022-02-09
- Fix incorrect parsing of parameters specified via the
-e/--extra-settingsoption flags (#2938) <https://github.com/getpelican/pelican/pull/2938> - Add
categories.htmltemplate to the default theme (#2973) <https://github.com/getpelican/pelican/pull/2973> - Document how to use plugins to inject content (#2922) <https://github.com/getpelican/pelican/pull/2922>
πΈ 4.7.1 - 2021-10-12
- Extend rich logging to the server component (#2927) <https://github.com/getpelican/pelican/pull/2927>
- Fix an issue where metadata flagged to be discarded was being cached (#2926) <https://github.com/getpelican/pelican/pull/2926>
- Adjust suffix in server to allow redirection when needed (#2931) <https://github.com/getpelican/pelican/pull/2931>
- Add MIME types for web fonts (#2929) <https://github.com/getpelican/pelican/pull/2929>
- Distribute sample data used to run tests (#2935) <https://github.com/getpelican/pelican/pull/2935>
- Add Python 3.10 to the test matrix
π 4.7.0 - 2021-10-01
- Improve default theme rendering on mobile and other small screen devices (#2914) <https://github.com/getpelican/pelican/pull/2914>
- Add support for hidden articles (#2866) <https://github.com/getpelican/pelican/pull/2866>
- Improve word count behavior when generating summary for CJK & other locales (#2864) <https://github.com/getpelican/pelican/pull/2864>
- Add progress spinner during generation (#2869) <https://github.com/getpelican/pelican/pull/2869> and richer logging (#2897) <https://github.com/getpelican/pelican/pull/2897>, both via Rich <https://github.com/willmcgugan/rich>
- Invoke tasks
serveandlivereloadnow auto-open a web browser pointing to the locally-served web site (#2764) <https://github.com/getpelican/pelican/pull/2764> - Support some date format codes used by ISO dates (#2902) <https://github.com/getpelican/pelican/pull/2902>
- Document how to add a new writer (#2901) <https://github.com/getpelican/pelican/pull/2901>
β¨ 4.6.0 - 2021-03-23
- Add new URL pattern to
PAGINATION_PATTERNSfor the last page in the list (#1401) <https://github.com/getpelican/pelican/issues/1401> - Speed up the
livereloadInvoke task via caching (#2847) <https://github.com/getpelican/pelican/pull/2847> - Ignore
Nonereturn value fromget_generatorssignal (#2850) <https://github.com/getpelican/pelican/pull/2850> - Relax dependency minimum versions and remove upper bounds
π 4.5.4 - 2021-01-04
Replace plugin definitions in settings with string representations after registering, so they can be cached correctly (#2828) <https://github.com/getpelican/pelican/issues/2828>.
π§ 4.5.3 - 2020-12-01
Fix a mistake made in PR #2821
π 4.5.2 - 2020-11-22
Improve logging of generators and writer loaders
π 4.5.1 - 2020-11-02
- Refactor intra-site link discovery in order to match more permissively (#2646) <https://github.com/getpelican/pelican/issues/2646>
- Fix plugins running twice in auto-reload mode (#2817) <https://github.com/getpelican/pelican/issues/2817>
- Add notice to use
from pelican import signalsinstead ofimport pelican.signals(#2805) <https://github.com/getpelican/pelican/issues/2805>
π 4.5.0 - 2020-08-20
- Add namespace plugin support; list plugins via
pelican-pluginscommand - Override settings via
-e/--extra-settingsCLI option flags - Add settings for custom Jinja globals and tests
- Customize article summary ellipsis via
SUMMARY_END_SUFFIXsetting - Customize Typogrify dash handling via new
TYPOGRIFY_DASHESsetting - Support Unicode when generating slugs
- Support Asciidoc
.adocfile generation in the Pelican importer - Improve user experience when
pelican --listenweb server is quit - Improve Invoke tasks template
- Include tests in source distributions
- Switch CI from Travis to GitHub Actions
- Remove support for Python 2.7
β 4.2.0 - 2019-10-17
- Support inline SVGs; don't treat titles in SVGs as HTML titles
- Add category to feeds (in addition to tags)
- Improve content metadata field docs
- Add docs for including other Markdown/reST files in content
π«Ά 4.1.3 - 2019-10-09
- Fix quick-start docs regarding
pelican --listen - Set default listen address to
127.0.0.1 - Add extra/optional Markdown dependency to
setup.py - Use correct SSH port syntax for
rsyncintasks.py - Place all deprecated settings handling together
- Add related project URLs for display on PyPI
- Skip some tests on Windows that can't pass due to filesystem differences
π 4.1.2 - 2019-09-23
Fix pelican.settings.load_source to avoid caching issues - PR #2621
π 4.1.1 - 2019-08-23
- Add AutoPub to auto-publish releases on PR merge
- Add CSS classes for reStructuredText figures
- Pass
argvto Pelican main entrypoint - Set default content status to a blank string rather than
None
π 4.1.0 - 2019-07-14
- Live browser reload upon changed files (provided via Invoke task)
- Add
pyproject.toml, managed by Poetry - Support for invoking
python -m pelican - Add relative source path attribute to content
- Allow directories in
EXTRA_PATH_METADATA - Add
all_articlesvariable to period pages (for recent posts functionality) - Improve debug mode output
- Remove blank or duplicate summaries from Atom feed
- Fix bugs in pagination,
pelican-import,pelican-quickstart, and feed importer
π¦ 4.0.1 (2018-11-30)
- Refactor
pelican.serverlogging - Fix bug in which all static files were processed as "draft"
- Bug fixes for Invoke/Makefile automation, Importer, and other miscellanea
β οΈ bestie, if you're upgrading from 3.7.x or earlier, please note that slug-related settings in 4.0+ use{slug}and/or{lang}rather than%s. If%s-style settings are encountered, Pelican will emit a warning and fall back to the default setting. Some user-submitted themes might try to format setting values but fail upon site build with aTypeError. In such cases, the theme needs to be updated. For example, instead ofTAG_FEED_ATOM|format(tag.slug), useTAG_FEED_ATOM.format(slug=tag.slug)
πΈ 4.0.0 (2018-11-13)
- Replace
develop_server.shscript withpelican --listen - Improved copy/link behavior for large static files (e.g., videos)
- New
{static}syntax to link to static content; content linked to by{static}and{attach}is automatically copied over even if not inSTATIC_PATHS - Pages can now have draft status
- Show current settings via new
--print-settingsflag - All settings for slugs now use
{slug}and/or{lang}rather than%s. If%s-style settings are encountered, Pelican will emit a warning and fallback to the default setting. - New signals:
feed_generatedandpage_generated_write_page - Replace Fabric with Invoke and
fabfile.pytemplate withtasks.py - Replace
PAGINATED_DIRECT_TEMPLATESbyPAGINATED_TEMPLATES, extending control over pagination to all templates and making page size variable - Replace
SLUG_SUBSTITUTIONS(and friends) bySLUG_REGEX_SUBSTITUTIONSfor more finegrained control '{base_name}'value inPAGINATION_PATTERNSsetting no longer strips'bar'from'foo/bar.html'(unless'bar'=='index').ARTICLE_ORDER_BYandPAGE_ORDER_BYnow also affect 1) category, tag and author pages 2) feeds 3) draft and hidden articles and pages- New
ARTICLE_TRANSLATION_IDandPAGE_TRANSLATION_IDsettings to specify metadata attributes used to identify/disable translations - Make the HTML reader parse multiple occurrences of metadata tags as a list
- New Blogger XML backup importer
- Wordpress importer now updates file links to point to local copies if the files were downloaded with
--wp-attach. - Importer no longer inserts extra newlines, to prevent breaking of HTML attributes.
- Pelican server now prioritises
foo.htmlandfoo/index.htmloverfoo/when resolvingfoo.
π 3.7.1 (2017-01-10)
- Fix locale issues in Quickstart script
- Specify encoding for
READMEandCHANGELOGinsetup.py
π 3.7.0 (2016-12-12)
- Atom feeds output
<content>in addition to<summary> - Atom feeds use
<published>for the original publication date and<updated>for modifications - Simplify Atom feed ID generation and support URL fragments
- Produce category feeds with category-specific titles
- RSS feeds now default to summary instead of full content; set
RSS_FEED_SUMMARY_ONLY = Falseto revert to previous behavior - Replace
MD_EXTENSIONSwithMARKDOWNsetting - Replace
JINJA_EXTENSIONSwith more-robustJINJA_ENVIRONMENTsetting - Improve summary truncation logic to handle special characters and tags that span multiple lines, using HTML parser instead of regular expressions
- Include summary when looking for intra-site link substitutions
- Link to authors and index via
{author}nameand{index}syntax - Override widget names via
LINKS_WIDGET_NAMEandSOCIAL_WIDGET_NAME - Add
INDEX_SAVE_ASoption to override defaultindex.htmlvalue - Remove
PAGEScontext variable for themes in favor ofpages SLUG_SUBSTITUTIONSnow accepts 3-tuple elements, allowing URL slugs to contain non-alphanumeric characters- Tag and category slugs can be controlled with greater precision using the
TAG_SUBSTITUTIONSandCATEGORY_SUBSTITUTIONSsettings - Author slugs can be controlled with greater precision using the
AUTHOR_SUBSTITUTIONSsetting DEFAULT_DATEcan be defined as a string- Use
mtimeinstead ofctimewhenDEFAULT_DATE = 'fs' - Add
--fatal=errors|warningsoption for use with continuous integration - When using generator-level caching, ensure previously-cached files are processed instead of just new files.
- Add Python and Pelican version information to debug output
- Improve compatibility with Python 3.5
- Comply with and enforce PEP8 guidelines
- Swap out tables in the settings documentation for
data::directives β slay, cleaner docs era π
3.6.3 (2015-08-14) π
- Fixed a permissions issue in the release tarball β no more cursed file modes, bestie π
3.6.2 (2015-08-01) πΈ
- Fixed installation errors related to Unicode in the tests β encoding drama, gone β¨
- The
notmyideatheme no longer shows pagination when there's only one page (iconic, honestly) - Hidden pages are now available in context π
- Improved
URLWrappercomparison β lowkey cleaner under the hood
3.6.0 (2015-06-15) π¦
- Caching is disabled by default now, so nobody gets confused by stale vibes
- Caching behavior improved overall β
picklegot swapped out forcpickle - You can now use Markdown or reST content in metadata fields other than
summary - Semicolon-separated author/tag lists are a thing now π
- Article sorting is way more flexible
- New
--relative-urlsargument β yes, that's the flag, exactly like that - The devserver can listen on addresses other than
localhostnow - HTTP server handlers unified into
pelican.serverthroughout - Intra-site links to draft posts actually get handled
tag_cloudmoved from core into a plugin- The default theme loads its external resources over HTTPS π
- Drafts can be imported from WordPress XML
- Better support for Windows users π«Ά
- Logging and the test suite got some glow-ups
- Codebase cleaned up and refactored
- New signals:
all_generators_finalizedandpage_writer_finalized
3.5.0 (2014-11-04) π
- Introduced the
ARTICLE_ORDER_BYandPAGE_ORDER_BYsettings so you can control the order of articles and pages β main character energy for your sorting - Time zone info is now included in dates rendered in templates
- The reader name is exposed in the metadata for articles and pages
- You can store static files alongside content in the same directory as articles and pages using
{attach}in the path β¨ - Pelican no longer throws an exception when a Markdown file has duplicate pieces of metadata
- Introduced the
TYPOGRIFY_IGNORE_TAGSsetting to add HTML tags that Typogrify should ignore - You can use
-in date formats to strip leading zeros β for example,%-d/%-m/%ynow gives you the date9/8/12 - Feed generation is correctly disabled during quickstart configuration
- Fixed
PAGE_EXCLUDESandARTICLE_EXCLUDESincorrectly matching sub-directories - Introduced the
STATIC_EXCLUDEsetting to add static file excludes - Fixed an issue when using
PAGINATION_PATTERNSwithRELATIVE_URLSenabled - Fixed feed generation causing links to use the wrong language for month names when using other locales π
- Fixed an issue where the authors list in the simple template wasn't formatted correctly
- Fixed an issue when parsing non-string URLs from settings
- Debug and warning messages are more consistent now
3.4.0 (2014-07-01) π₯
- Content generation got way faster thanks to a new caching mechanism
- Selective post generation is here β you don't have to rebuild the entire site every single time
- Lots of documentation improvements, including switching to the prettier RtD theme π
- Support for multiple content and plugin paths
- Added the
:modified:metadata field to complement:date:β it specifies the last date and time an article was updated, independent of when it was published - Support for multiple authors via the new
:authors:metadata field π - Static directories are watched for changes in auto-regeneration mode
- Filters added to limit log output when you want things quiet
- Drafts support language now
- Added the
SLUGIFY_SOURCEsetting to control how post slugs are generated - Fixed a ton of issues relating to locale and encoding
- The Typogrify filter gets applied to post summaries now
- File metadata (like timestamps) is preserved when copying static files to output
- AsciiDoc support moved from Pelican core into a separate plugin
- Importing content produces inline links instead of reference-style links
- Better handling of
IGNORE_FILESsetting behavior - Symbol characters in tag names are properly escaped now (so
C++finally behaves) - Minor tweaks for Python 3.4 compatibility
- Several new signals added
3.3.0 (2013-09-24) π
- Dropped Python 3.2 support in favor of Python 3.3 β bye bestie π
- Added a Fabfile so Fabric can be used for workflow automation instead of
Make - The
OUTPUT_RETENTIONsetting can preserve metadata (like VCS data such as.hgand.git) from being removed from the output directory - Tumblr import π
- Improved logic and consistency when cleaning the output folder
- Better documentation versioning and release automation
- Improved pagination flexibility
- Signals renamed for better consistency β heads up, some plugins may need to be updated
- Metadata extraction moved from generators to readers, and it's no longer article-specific
FILES_TO_COPYis deprecated in favor ofSTATIC_PATHSandEXTRA_PATH_METADATA- Summaries in Markdown posts no longer include footnotes
- Unnecessary whitespace removed from output via the
lstrip_blocksJinja parameter - PDF generation moved from core to a plugin
MARKUPsetting replaced withREADERS- You get a warning if an
imgtag is missing itsaltattribute β οΈ - Added support for
{}in relative link syntax, besides|| - Added support for
{tag}and{category}relative links - Added a
content_writtensignal
3.2.1 and 3.2.2 π
- Facilitated inclusion in the FreeBSD Ports Collection
3.2 (2013-04-24) π
- Support for Python 3! periodt.
- Override a page's save-to location from meta-data β which means you can use a static page as the site's home page, for example
- Time period archives: per-year, per-month, and per-day archives of posts ποΈ
- Posterous blog import
- Improved WordPress blog import
- Plugins migrated to a separate repository
- Improved the HTML parser
- Show or hide categories from the menu using the
DISPLAY_CATEGORIES_ON_MENUoption - Auto-regeneration can be told to ignore files via the
IGNORE_FILESsetting - Improved post-generation feedback to the user
- For multilingual posts, use meta-data to designate which version is the original and which is the translation
- Added
.mdownto the list of supported Markdown file extensions - Document-relative URL generation (
RELATIVE_URLS) is now off by default
3.1 (2012-12-04) π§
- The importer now stores slugs within files by default β you can turn this off with the
--disable-slugsoption - Improved handling of links to intra-site resources
- WordPress import now adds paragraphs for all types of line endings in post content
- HTML entities within WordPress post titles are decoded on import
- Improved the appearance of the LinkedIn icon in the default theme
- Added GitHub and Google+ social icons support in the default theme
- Optimized social icons
- Added
FEED_ALL_ATOMandFEED_ALL_RSSto generate feeds containing all posts regardless of their language - Split
TRANSLATION_FEEDintoTRANSLATION_FEED_ATOMandTRANSLATION_FEED_RSS - Feeds can now be enabled/disabled individually
- Blank author allowed: if the
AUTHORsetting isn't set, the author no longer defaults to${USER}, and a post won't contain any author information if the post author is empty - LESS and Webassets support moved from Pelican core to a plugin
- The
DEFAULT_DATEsetting now defaults toNone, which means articles won't be generated unless date metadata is specified π«Ά - Added the
FILENAME_METADATAsetting to support metadata extraction from the filename - Added the
gzip_cacheplugin to compress common text files into a.gzfile in the same directory as the original, so the server (like Nginx) doesn't have to compress files during an HTTP call - Added support for AsciiDoc-formatted content
- Added the
USE_FOLDER_AS_CATEGORYsetting so that feature can be toggled on/off - Support for arbitrary Jinja template files
- Restored basic functional tests
- New signals:
generator_init,get_generators, andarticle_generate_preread
3.0 (2012-08-08) π«
- Refactored the way URLs are handled
- Improved the English documentation
- Fixed packaging using setuptools entrypoints
- Added typogrify support
- Added a way to disable feed generation
- Added support for
DIRECT_TEMPLATES - Multiple extensions allowed for content files
- Added LESS support
- Improved the import script
- Added functional tests
- Rsync support in the generated
Makefile - Improved feed support β easily pluggable with Feedburner, for instance
- Added support for
abbrin reST - Fixed a bunch of bugs :-)
2.8 (2012-02-28) π
- Dotclear importer
- Markdown extensions can be used now
- Themes are easily extensible now
- No pagination information output when there's only one page
- Added a page per author, with all their articles
- Improved the test suite
- Made themes easier to extend (yes, again β it was that serious)
- Removed Skribit support
- Added a
pelican-quickstartscript β¨ - Fixed timezone-related issues
- Added some scripts for Windows support
- Date can be specified in seconds
- Never fails when generating posts β it skips and continues
- Future dates are allowed
- Support for different timezones per language
- Enhanced the documentation
2.7 (2011-06-11) πΈ
- Uses logging rather than echoing to stdout
- Custom Jinja filters support
- Compatibility with Python 2.5
- Added a theme manager
- Packaged for Debian
- Added draft support π
2.6 (2011-03-08) π¦
- Changes in the output directory structure
- Makes templates easier to work with and create
- Added RSS support (it was Atom-only before)
- Added tag support for feeds
- Enhanced the documentation
- Added another theme (
brownstone) - Added translations
- Added a way to use cleaner URLs with a rewrite url module (or equivalent)
- Added a tag cloud
- Added an autoreloading feature: the blog is automatically regenerated each time a modification is detected π
- Translated the documentation into French
- Import a blog from an RSS feed
- Pagination support
- Added Skribit support
2.5 (2010-11-20) π
- Import from WordPress
- Added some new themes (
martyalchin/wide-notmyidea) - First bug report! π iconic
- LinkedIn support
- Added a FAQ
- Google Analytics support
- Twitter support
- Uses relative URLs, not static ones
2.4 (2010-11-06) π
- Minor theme changes
- Added Disqus support, so we have comments π¬
- Another code refactoring
- Added config settings about pages
- Blog entries can also be generated in PDF
2.3 (2010-10-31) π
- Markdown support
2.2 (2010-10-30) β
- Prettified the output
- Manages static pages as well
2.1 (2010-10-30) π
- Made
notmyideathe default theme
π¦ 2.0 (2010-10-30)
- Refactoring to be more extensible β¨
- Change into the setting variables π
π 1.2 (2010-09-28)
- Added a debug option π
- Added per-category feeds π
- Use filesystem to get dates if no metadata is provided π
- Add Pygments support π
πΈ 1.1 (2010-08-19)
- First working version π β the origin story, fr fr
π AUTHOR π
Justin Mayer β that's the icon behind all this π«Ά
π§ COPYRIGHT π§
2010β2026 β like, sixteen whole years of lore, no cap πβ¨
okay bestie, that's the whole page, start to finish β you made it to the very end and I'm so proud of you ππ This little beauty you're holding is version 4, dated Oct 04, 2026, and it goes by the name PELICAN(1). Go build something iconic with it. Slay the day. Periodt. ππ¦β
π¦ where this page comes from
- arch rolling: pelican 4.12.0-1 Β· AGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms