倒腾Pelican - Elegant Set Sidebar
Default sidebar options
According to the metadata in your articles,sidebar shows:
1. You can activate Pushlish date
, Modification date
, Category
, Tags
functions by specify optional meta data variables Date
, Modified
, Category
and Tags
when editing your articles.
2. Social links
is set in your ‘pelicanconfig.py’, just add your links to the Dictionary
# Social widget |
3. To set your Mailchimp subscribe box
, just refer to article Mailchimp subscribe.
Add more options
You can do some modification to the elagant themes source code to show more informations on your right sidebar.
Let’s what can we get:
“Author”
Remember that we have specified author
meta in our articles, but elegant theme does not support showing this on sidebar.
step 1. Add author.html
under path pelican-elegant/templates/_includes/
, don’t worry about the source code of this file, your can copy _includes/last_updated.html
and make some modifications:
Details of these two files:
author.html
:
<!-- modified by Jiheng Hu --> |
last_updated.html
:
{# Check which version of Pelican user is using. |
step 2. Modify pelican-elegant/templates/article.html
Find the following parts:
{% include '_includes/last_updated.html' %} |
Add the following line to after it:
{% include '_includes/author.html' %} <!-- added by Jiheng Hu so is file "_include/author.html" --> |
step 3. Add author
as a meta in your articles and update your blog, you can see the author is attached to to sidebar.
“multi_parts” plugin
The elegant theme support Multi-parts
plugin to label posts as parts of a series, the series list is located on sidebar。
You can add ‘multi-parts’ to PLUGINS
list in pelicanconfig.py
:
PLUGINS = [u"neighbors",u"related_posts","tag_cloud","share_post","sitemap","extract_toc","multi_part"] |
Add in your markdown articles of the same serie:
parts: Serie name |
You can see a list on sidebar.
See also multi_part.
“series” plugin
The series
plugin is a substitution of multi_part
, the reasons we choose the formal one are that:
1. Expand PLUGINS
with 'multi_part'
will bring in a warning:
WARNING: multi_part plugin: this plugin has been deprecated. |
2. We can specify the part index for each parts and series
will list them in the order of indices, while multi_part
can not make it.
However, elegant do not support series
plugin, we need to modify 'pelican-elegant/templates/article.html'
again.
step 1. Add a author.html
under path pelican-elegant/templates/_includes/
, the souce code comes from Github.
{% if article.series %} |
step 2. Add a if conditional clauses
to multi_part
in 'pelican-elegant/templates/article.html'
.
{% if 'multi_part' in PLUGINS %} <!-- added by Jiheng Hu --> |
step 3. Add following after step 2 code, also with a if conditional clauses
.
html{% if 'series' in PLUGINS %} <!-- added by Jiheng Hu -->
{% include '_includes/series.html' %} <!-- added by Jiheng Hu, so is file "_include/series.html" -->
{% endif %} <!-- added by Jiheng Hu -->
```
***step 4.*** Expand `PLUGINS` list with `'series'`, meantime, remove `'multi-parts'` for the list, otherwise you will get two series list on sidebar.
```python
PLUGINS = [u"neighbors",u"related_posts","tag_cloud","share_post","sitemap","extract_toc","series"]#,"multi_part"]
step 5. Use meta data in your articles.
markdownseries: series name
series_index: 1
See also series.
{% if 'series' in PLUGINS %} <!-- added by Jiheng Hu --> |
series: series name |
The effect of above setting
Tip: you can customize the order of sidebar elements by adjusting their quote orders in article.html
.