How to Use a Custom Pelican Blog Theme?

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.

Part 1: Quickstart a pelican blog in 5 minutes
Part 3: How to publish pelican blog on GitHub Pages?

1. Prerequisite

  1. *nix based machine (GNU/Linux, Mac, etc)
  2. A Pelican Blog

2. Specifications

In this tutorial I am using the following:

Ubuntu: v20.04
Pelican: v4.2.0
Python: v3.8.2

3. Initial Step

  1. Change to pelican blog directory $cd myblog/
  2. Activate python virtualenv (if you are using) $workon myblog/

4. See available themes

For this, we’ll use the default CLI tool that comes with Pelican. That is Pelican-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 git@github.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.

11. Output

Expected

Actual

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

make publish

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?

16. Conclusion

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 🙂

Trivia:
Q. Why Pelican is called Pelican?
A. “Pelican” is an anagram of calepin, which means “notebook” in French.

17. Further Read

  1. Quickstart a pelican blog in 5 minutes
  2. How to publish pelican blog on GitHub Pages?
  3. More about Pelican-Theme CLI tool: https://docs.getpelican.com/en/stable/pelican-themes.html

18. References

  1. https://docs.getpelican.com/en/stable/pelican-themes.html

2 thoughts on “How to Use a Custom Pelican Blog Theme?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s