I did the following to enable Table of Contents display, on the side of posts, in Elegant theme:
Enable toc
extension¶
Python Markdown's extension Table of Contents
MARKDOWN = {
'extension_configs': {
'markdown.extensions.toc': {}
}
}
Install extract_toc
¶
Install the Pelican's plugin extract_toc
- this plugin is part of
pelican-plugins
repository - at some point, this plugin should be moved to its own repository
- to save on downloading the whole repo, I'm simply to going to copy it here
mkdir plugins
cd plugins
git clone https://github.com/getpelican/pelican-plugins.git
cp -r pelican-plugins/extract_toc .
Install extract_toc
's dependency¶
Add to requirements.txt
beautifulsoup4
Enable extract_toc
¶
Add to pelicanconf.py
:
PLUGIN_PATHS = [
"plugins"
]
PLUGINS = [
"extract_toc"
]
Enable permalinks¶
Add setting to Python Markdown TOC extension to enable permalinks to posts' headings:
MARKDOWN = {
'extension_configs': {
'markdown.extensions.toc': {}
}
}
Sources
- extract_toc's README
- Elegant's documentation: Add a Table of Contents to Your Articles
- Elegant's documentation: Permalinks to Headings