Quickstart a Pelican Blog in 5 Minutes

Greetings! If you want to start your static blog, and you are interested to use Pelican for that, then this blog post will help you to achieve it as soon as possible. Let’s get started!

This is part 1 of 3 in my trilogy of Pelican Tutorials. Following are the next 2 parts in this series.

Part 2: How to use a custom pelican blog theme?
Part 3: How to publish pelican blog on GitHub Pages?

1. Prerequisite

  1. *nix based machine (GNU/Linux, Mac, etc)
  2. Python Basics
  3. Markdown/reStructuredText Basics
  4. What is Pelican? https://docs.getpelican.com/en/4.2.0/

2. Specifications

I am using the following in this tutorial

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

3. Create an empty directory

mkdir myblog

4. Change to the new directory

cd myblog

5. Create python virtual environment

mkvirtualenv myblog

You may use any tool to create a python virtual environment. Though, I use virtualenvwrapper.

6. Activate the newly created virtualenv

workon myblog

7. Pip install requirements

pip install pelican Markdown

8. Pelican-Quickstart

Run the following command and answer a few questions

pelican-quickstart
Welcome to pelican-quickstart v4.2.0.

This script will help you create a new Pelican-based website.

Please answer the following questions so this script can generate the files
needed by Pelican.

    
> Where do you want to create your new web site? [.] 
> What will be the title of this web site? My New Blog
> Who will be the author of this web site? GeekyShacklebolt
> What will be the default language of this web site? [en] 
> Do you want to specify a URL prefix? e.g., https://example.com   (Y/n) y
> What is your URL prefix? (see above example; no trailing slash) https://geekyshacklebolt.github.io/blog
> Do you want to enable article pagination? (Y/n) y
> How many articles per page do you want? [10] 5
> What is your time zone? [Europe/Paris] US/Eastern
> Do you want to generate a tasks.py/Makefile to automate generation and publishing? (Y/n) Y
> Do you want to upload your website using FTP? (y/N) n
> Do you want to upload your website using SSH? (y/N) n
> Do you want to upload your website using Dropbox? (y/N) n
> Do you want to upload your website using S3? (y/N) n
> Do you want to upload your website using Rackspace Cloud Files? (y/N) n
> Do you want to upload your website using GitHub Pages? (y/N) y
> Is this your personal page (username.github.io)? (y/N) n
Done. Your new project is available at /home/shiva/tmp/myblog

Note: Make sure to say “yes” when prompt for generating “makefiles” in pelican-quickstart setup wizard. Because this Makefile will be very handy for later operations.

Now, the contents of your myblog directory should be as follows:

myblog
├── content
├── Makefile
├── output
├── pelicanconf.py
├── publishconf.py
└── tasks.py

2 directories, 4 files

9. Add some content

touch ./content/my-first-post.md
tree .
.
├── content
│   └── my-first-post.md
├── Makefile
├── output
├── pelicanconf.py
├── publishconf.py
└── tasks.py

2 directories, 5 files

You may add the following content in your my-first-post.md:

Title: My First Post
Date: 2020-08-18 12:13
Category: All

Hello Pelican! How are you?

Note: You may also use the syntax of reStructuredText instead of Markdown. But for that you’ll have to install required pip packages to support reStructuredText.

10. Locally build your site

make html

11. Locally run your site

make serve

Now go to http://127.0.0.1:8000 in your browser to view your blog.

12. Publish your site

make publish

Now, the output directory in your blog is ready to deploy wherever you want.

13. Change Theme

If you would like to get a quick overview on how to change the default pelican theme and use some custom themes, then please follow the Part 2 of this series How to use a custom pelican blog theme?

14. 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?

15. Conclusion

Pelican is an easy to use static site generator. I love it. And I am using it for my personal blog available at https://www.ShivaSaxena.com/blog

Thanks for reading!
See you in the next post 🙂

PS: Python is everywhere!

16. Further read

  1. How to use a custom pelican blog theme?
  2. How to publish pelican blog on GitHub pages?
  3. Pelican official documentation: https://docs.getpelican.com/en/4.2.0/

17. References

  1. https://docs.getpelican.com/en/4.2.0/

2 thoughts on “Quickstart a Pelican Blog in 5 Minutes

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