Greetings! You are here, that means you want to change your default pelican theme. The procedure is really easy. But what takes time, is choosing a new theme from a large number of available themes out there. In this post, find out how to add or remove these customized pelican blog themes.
This is part 2 of 3 in my trilogy of Pelican Tutorials. It is recommended that you read the previous part 1 for better understanding of this current part 2.
- *nix based machine (GNU/Linux, Mac, etc)
- A Pelican Blog
In this tutorial I am using the following:
Ubuntu: v20.04 Pelican: v4.2.0 Python: v3.8.2
3. Initial Step
- Change to pelican blog directory $cd myblog/
- Activate python virtualenv (if you are using) $workon myblog/
4. See available themes
pelican-themes --list notmyidea simple pelican-themes --list --verbose /venv/lib/python3.8/site-packages/pelican/themes/notmyidea /venv/lib/python3.8/site-packages/pelican/themes/simple
5. See currently active theme
pelican --print-settings THEME 'THEME': '/venv/lib/python3.8/site-packages/pelican/themes/notmyidea',
6. Download your new theme
You may choose your new pelican themes from here http://www.pelicanthemes.com/
For this tutorial I am selecting: Attila. Once selected, download/clone the theme on your machine.
git clone email@example.com:arulrajnet/attila.git
Note: This downloaded theme must not be zipped or compressed. If it is, then you need to unzip it before proceeding in the tutorial.
7. Install this new theme in pelican
pelican-themes --install attila --verbose Installing themes... Copying 'attila' to '/venv/lib/python3.8/site-packages/pelican/themes/attila'
Syntax is: pelican-themes –install /path/to/theme/to/install –verbose
8. Verify the installation
pelican-themes --list --verbose /venv/lib/python3.8/site-packages/pelican/themes/notmyidea /venv/lib/python3.8/site-packages/pelican/themes/simple /venv/lib/python3.8/site-packages/pelican/themes/attila
9. Configure blog to use new theme
For this, just open your pelicanconf.py available in your blog directory and define the path to your new theme by adding the following statement at the end of pelicanconf.py file:
THEME = '/venv/lib/python3.8/site-packages/pelican/themes/attila'
10. Rebuild and run the site locally
make html serve
Now go to http://127.0.0.1:8000 in your browser to view your blog.
12. Why actual theme is different than expected?
Because, there exist some configuration options which are specific to the theme we choose. In this case, the theme is Attila, and in there docs, all the configuration option are mentioned here and in their README.
Let’s add the Header Cover as mentioned in their configuration options. We just need to set this configs in our pelicanconf.py
HOME_COVER = 'https://geekyshacklebolt.github.io/blog/images/my-blog-header-bg.jpg'
Rebuild and run the site
make html serve
13. Better Output
Similarly, using all the configuration option you may customize the theme as per your convenience.
14. Publish your site
Now the output directory in your blog is ready to deploy wherever you want.
15. Publish to GitHub pages
Since not everyone like to publish their blog on GitHub, this topic is covered in Part 3 of this trilogy How to publish pelican blog on GitHub pages?
For me, choosing a new theme for anything is hectic and fun together. After trying so many pelican themes. I finally selected Pelican-Clean-Blog theme by Gilson Filho. If you want to see, my pelican blog is available at: https://www.ShivaSaxena.com/blog
Thanks for reading!
See you in the next post 🙂
Q. Why Pelican is called Pelican?
A. “Pelican” is an anagram of calepin, which means “notebook” in French.
17. Further Read
- Quickstart a pelican blog in 5 minutes
- How to publish pelican blog on GitHub Pages?
- More about Pelican-Theme CLI tool: https://docs.getpelican.com/en/stable/pelican-themes.html