Pelican allows you to create a static blog. Most blog sites on the web are dynamic in the sense that the content of the site live in a database. In order to view a post on a blog, the server has to query the database, get the right content and then convert it into presentable HTML. However, in a static site, every page is pre-rendered by the static blog generator. This means that your entire blog can be uploaded to a server.
Create a folder in the directory where you want the blog to be created. This directory will contain all the related files and folders. Suppose you want the blog to be created in D:\ directory and project folder name to be MyBlog, use these commands from your command prompt.
D:\>mkdir MyBlog
D:\>cd MyBog
D:\MyBlog\>
Installing Pelican
Make a file requirements.txt int the current folder D:\MyBlog\ with the following content :
Markdown
pelican
Run pip install -r requirements.txt from the command prompt. We can use requirements.txt file to install several libraries at once.
D:\MyBlog\>pip install -r requirements.txt
Basic Setup
Run pelican quickstart and you will be asked sequence of questions. There's no need to change much in the default quickstart wizard. Default values are indicated by [default] and (y/N) , where the capitalized letter is the default value. Just one thing to note here is URL prefix; don't set it right now, set it when you actually want to take your site online.
D:\MyBlog\\>pelican-quickstart
Welcome to pelican-quickstart v3.6.3.
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? Pandey's Blog
Who will be the author of this web site? Suryansh Pandey
What will be the default language of this web site? [en]
Do you want to specify a URL prefix? e.g., http://example.com (Y/n) n
Do you want to enable article pagination? (Y/n)
How many articles per page do you want? [10] 6
What is your time zone? [Europe/Paris] Asia/Kolkata
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)
Done. Your new project is available at D:\MyBlog
Now the structure of MyBlog folder should look like :
MyBlog
├── content/
├── output/
├── develop_server.sh
├── fabfile.py
├── Makefile
├── pelicanconf.py # Main settings file
├── publishconf.py # Settings to use when ready to publish
└── requirements.txt
If you see your content and output folder, they will be empty because we have not created any post yet. So lets create out first post.
Your First Post
Pelican supports reStructuredText format to write posts, but if you like to use other format like Markdown you can install it using pip install markdown(we have already installed markdown) or if you want to use jupyter to write your posts you can install this plugin.
In this post we will write our first post using markdown format.
content folder will contain all the posts that your create. So lets change our working directory to content\
D:\MyBlog\>cd content
D:\MyBlog\content\>
Create a file first_post.md in this folder and write the following content into the file.
Title: My First blog article
Date: 2017-12-25 08:00
Tags: pelican, markdown
Category: Tech
Slug: my-first-blog-article
Description: This post is my first article.And here goes the content of this post
I have written using markdown format and used pelican for making this website.
Generating HTML
Save the file first_post.mdand switch to main directory i.e. D:\MyBlog\ and run the command pelican content
D:\MyBlog\>pelican content
Done: Processed 1 article, 0 drafts, 0 pages and 0 hidden pages in 0.70 seconds.
After running this command your directory structure should look like
MyBlog
├── content/
└── first_post.md
├── output/
├──author/
├──category/
├──tag/
├──theme/
├──archieves.html
├──authors.html
├──categories.html
├──first_post.html
├──index.html
└── tags.txt├── develop_server.sh
├── fabfile.py
├── Makefile
├── pelicanconf.py # Main settings file
├── publishconf.py # Settings to use when ready to publish
└── requirements.txt
Publishing your First Post
First switch to output directory and then run the command python -m pelican.server
D:\MyBlog\>cd output
D:\MyBlog\output\>python -m pelican.server
You can check your blog now by going to the following url localhost:8000
There you Go!!
So now you are up and running with the website locally. In the next post I will go through how we can write posts using jupyter and how to host the website using Github Pages.