Installing pelican on Mac OSX and develop your first blog

Pelican is a static site generator developed in python and specialized in blogging. To know more details about pelican, visit their blog, docs and github.

I wanted to use github pages for my personal site. Github pages like static html pages. I tried their recommended static site generator Jekyll. But I didn't like it because it was lots of hassle for me. Changing themes was like a nightmare and it never worked for me. I tried and tried and then give up. Then I started to search for alternative static site generator. I was looking something was built in python as recently I am working mostly on python, so I thought it would also be helpful for me for learning a new blogging platform in python. So, here comes Pelican.

Create a directory where you want to develop your Pelican site. Go into that directory.

Then create a python virtual enviroment.

$ virtualenv -p python3 venv/pelican

This command creates a directory called venv inside the root blog directory you just created and installs the virtualenv inside another directory called pelican.

Activate the pelican virtual enviroment.

$ source venv/pelican/bin/activate

Next install Pelican using pip.

$ pip install pelican

You will also need the MarkDown module to be able to write your content in markdown format. Install it using the following command:

$pip install markdown

Check the pelican version using this command (mine was 3.7.1):

$ pelican --version

Next create your site by executing the following command:

$ pelican-quickstart

It will ask you couple of questions. Answer those and your basic site will be generated. Here are a list of questions I was asked:

> Where do you want to create your new web site? [.]
> What will be the title of this web site? My Personal Pelican Site
> Who will be the author of this web site? Moshfiqur Rahman
> What will be the default language of this web site? [en]
> Do you want to specify a URL prefix? e.g.,   (Y/n) n
> Do you want to enable article pagination? (Y/n)
> How many articles per page do you want? [10]
> What is your time zone? [Europe/Paris] Europe/Berlin
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n)
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)
> Do you want to upload your website using FTP? (y/N)
> Do you want to upload your website using SSH? (y/N)
> Do you want to upload your website using Dropbox? (y/N)
> Do you want to upload your website using S3? (y/N)
> Do you want to upload your website using Rackspace Cloud Files? (y/N)
> Do you want to upload your website using GitHub Pages? (y/N) y
> Is this your personal page ( (y/N) y
Done. Your new project is available at /path/to/your/blog/folder

There will be a directory created called content. This is the default place where you suppose to create your blog post. You can use markdown format to write your content. Create some dummy content to give it a try:

Title: Hello World
Date: 2018-07-14 22:14:00
Category: hello world

I have created this blog to say hello to the world.

Now execute the following command to generate your site:

$ pelican content

This will generate your site with similar output:

Done: Processed 1 articles, 0 drafts, 0 pages and 0 hidden pages in 0.10 seconds.

Please note that this will use the default pelican conf file to generate new pages and articles. To publish your site, you might have some extra settings only available for live site in In such cases, you can tell pelican which conf file to use to generate site using this following command:

$ pelican content -s

If you check, you will see there is a directory called output has been created in your root blog directory which contains all the static html files for your blog including js, css and theme files. Those are the files you would like to upload in your github pages.

Before that you might like to test your site locally. Pelican comes with a built in development web server. To test your site, go inside the output directory, execute the following command:

$ python -m pelican.server

Alternatively, you can run this command too from the blog root directory:

$ make serve

Now, visit the site locally at http://localhost:8000. Congratulations! You just created your first Pelican powered personal site.

During developing, you might want to automatically generate your site as it will be boring to generate the site by hand everytime you do some changes. To do this, run this command in terminal:

$ pelican -r

So, it will now continuously monitor the content, theme and settings for changes and will auto generate your site if it detect any changes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top