Configuration
Turbopelican eliminates the need to use two scripts (pelicanconf.py
and
publishconf.py
) for configuring Pelican by providing a pelicanconf.py
script which will correctly load the appropriate configuration depending on
your situation. As a result, you will want to modify your turbopelican.toml
configuration file. You do not need to modify pelicanconf.py
.
Using TOML to configure Pelican
Pelican has a
number of settings
which can be changed according to your need. Turbopelican allows you to define
them in turbopelican.toml
instead. By default it should look something like
this:
[pelican]
author = "Elliot Simpson"
sitename = "MySite"
timezone = "Pacific/Auckland"
default_lang = "en"
path = "content"
default_pagination = false
theme = "themes/plain-theme"
article_paths = []
page_paths = [""]
page_save_as = "{slug}.html"
static_paths = ["static", "images"]
index_save_as = ""
author_feed_atom = "None"
author_feed_rss = "None"
category_feed_atom = "None"
feed_all_atom = "None"
translation_feed_atom = "None"
[[pelican.extra_path_metadata]]
origin = "static/favicon.ico"
path = "favicon.ico"
[[pelican.extra_path_metadata]]
origin = "images/logo.svg"
path = "logo.svg"
[publish]
site_url = "https://turbopelican.github.io"
relative_urls = false
feed_all_atom = "feeds/all.atom.xml"
category_feed_atom = "feeds/{slug}.atom.xml"
delete_output_directory = true
The simple rule is that settings under [pelican]
configure Pelican during
development, while settings under [publish]
configure Pelican during
publication. Because most of your settings will be mostly the same in both
contexts, settings not defined in [publish]
will fallback to those defined
in [pelican]
if possible.
The name of all settings should be the same as those in Pelican
, except
lowercase. The only exception is SITEURL
which is written within the TOML as
site_url
with an underscore.
Where Pelican expects tuples or lists, use arrays. Where Pelican expects
dictionaries, use tables. There is one exception to this. The
EXTRA_PATH_METADATA
setting in Pelican needs to be a dictionary, for
example:
EXTRA_PATH_METADATA = {
"static/favicon.ico": {"path": "favicon.ico"},
"images/logo.svg": {"path": "logo.svg"},
}
To achieve this in turbopelican.toml
, the keys of EXTRA_PATH_METADATA
are
flattened into the values with the key "origin"
:
[[pelican.extra_path_metadata]]
origin = "static/favicon.ico"
path = "favicon.ico"
[[pelican.extra_path_metadata]]
origin = "images/logo.svg"
path = "logo.svg"
Refer to the Pelican documentation for what each setting does.
Special values
The pelicanconf.py
file needs to be capable of containing settings with
values of None
. In some cases, certain settings will need to contain
functions. TOML does not natively contain either of these concepts.
None values
By default, Turbopelican will swap any "None"
string values for None
. If
this causes an issue, it is possible to change the sentinel value
(meta.null_sentinel
) to something like -1
:
[meta]
null_sentinel = -1
[pelican]
analytics = -1 # Becomes `None`
Or "TurboPelicanNull"
like so:
[meta]
null_sentinel = "TurboPelicanNull"
[pelican]
author = "TurboPelicanNull" # Becomes `None`
Functions
Breaking the strictest conventions of configuration, Pelican can be configured with functions. Though TOML has no native concept of functions, Turbopelican lets you parse strings as functions like so:
[[meta.module_prefix]]
prefix = "@urlencode:"
module_name = "custom_filter"
[pelican]
jinja_filters = {urlencode = "@urlencode:urlencode_filter"}
This is equivalent to the following Python:
from custom_filter import urlencode_filter
JINJA_FILTERS = {
"urlencode": urlencode_filter
}
Whenever a prefix
value is found beneath [pelican]
or [publish]
, the
subsequent string is treated as the name of the function to be imported from
the module with the specified module_name
. Note that this means the module
should be found from the PYTHONPATH
.
Configuration settings index
- analytics
- archives_save_as
- article_excludes
- article_lang_save_as
- article_lang_url
- article_order_by
- article_paths
- article_save_as
- article_translation_id
- article_url
- author
- authors_save_as
- author_feed_atom
- author_feed_atom_url
- author_feed_rss
- author_feed_rss_url
- author_regex_substitutions
- author_save_as
- author_url
- bind
- cache_content
- cache_path
- categories_save_as
- category_feed_atom
- category_feed_atom_url
- category_feed_rss
- category_feed_rss_url
- category_regex_substitutions
- category_save_as
- category_url
- check_modified_method
- content_caching_layer
- css_file
- date_formats
- day_archive_save_as
- day_archive_url
- default_category
- default_date_format
- default_lang
- default_metadata
- default_orphans
- default_pagination
- delete_output_directory
- direct_templates
- display_categories_on_menu
- display_pages_on_menu
- disqus_sitename
- docutils_settings
- draft_lang_save_as
- draft_lang_url
- draft_page_lang_save_as
- draft_page_lang_url
- draft_page_save_as
- draft_page_url
- draft_save_as
- draft_url
- extra_path_metadata
- feed_all_atom
- feed_all_atom_url
- feed_all_rss
- feed_all_rss_url
- feed_append_ref
- feed_atom
- feed_atom_url
- feed_domain
- feed_max_items
- feed_rss
- feed_rss_url
- filename_metadata
- formatted_fields
- github_url
- gzip_cache
- ignore_files
- index_save_as
- intrasite_link_regex
- jinja_environment
- jinja_filters
- jinja_globals
- jinja_tests
- links
- links_widget_name
- load_content_cache
- locale
- log_filter
- markdown
- menuitems
- month_archive_save_as
- month_archive_url
- newest_first_archives
- output_path
- output_retention
- output_sources
- output_sources_extension
- page_excludes
- page_lang_save_as
- page_lang_url
- page_order_by
- page_paths
- page_save_as
- page_translation_id
- page_url
- paginated_templates
- pagination_patterns
- path
- path_metadata
- plugins
- plugin_paths
- port
- pygments_rst_options
- readers
- relative_urls
- reverse_category_order
- rss_feed_summary_only
- sitename
- sitesubtitle
- site_url
- slugify_preserve_case
- slugify_source
- slugify_use_unicode
- slug_regex_substitutions
- social
- social_widget_name
- static_check_if_modified
- static_create_links
- static_excludes
- static_exclude_sources
- static_paths
- stylesheet_url
- summary_end_suffix
- summary_max_length
- summary_max_paragraphs
- tags_save_as
- tag_feed_atom
- tag_feed_atom_url
- tag_feed_rss
- tag_regex_substitutions
- tag_save_as
- tag_url
- template_extensions
- template_pages
- theme
- theme_static_dir
- theme_static_paths
- theme_templates_overrides
- timezone
- translation_feed_atom
- translation_feed_atom_url
- translation_feed_rss
- translation_feed_rss_url
- twitter_username
- typogrify
- typogrify_dashes
- typogrify_ignore_tags
- typogrify_omit_filters
- use_folder_as_category
- with_future_dates
- year_archive_save_as
- year_archive_url