Create a static blog with Pelican
Fri 14 March 2014
This is a quick tutorial on how to create a static blog with Pelican for my friend, Javed.
Now other source code hosting services like Bitbucket also followed the trend and hence you see my blog! When you type in sindhus.bitbucket.org, your web browser queries bitbucket and bitbucket does its job by responding with a standard 201 HTTP code and follows it up by looking for a "index.html" file. If such a file is found then sindhus.bitbucket.org is loaded and the page that loads on your browser is index.html.
In Arch Linux, you can install it with these two steps:
sudo pacman -S python2-pip
Pip is a python package manager. A python package may be dependent on other python packages for it's correct working and pip manages installation of python packages for you.
pip2 install --user pelican
This tells pip to install Pelican just for you in your home folder. If you don't use --user, then you will require to use sudo to install pelican system-wide.
To create a blog:
pelican-quickstartand follow the instructions on the screen.
After you have successfully created a blog, you can view it locally with:
lsto check the new files created for you by step 1. You should see a file
develop_server.sh, this script will run your blog locally for you. Run
./develop_server startand go to a browser, open
All the blog content will be in the folder called
content. To add a new blog post, you create a new file with the format:
Title: Your title here Slug: your-title-here Date: 2014-03-14 Category: Tags:
I personally recommend keeping separate folders for different categories and creating your blog posts in those folders. I don't use 'Tags' but you can use it if you want to.
After doing the
ls, you will also see a file that was created automatically for you called
publishconf.py. You can customise the settings of your blog as per your choice. To know what you can customise, refer to the official documentation or even better is Terry Yu's post on How I setup Pelican
My pelican.conf is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/usr/bin/env python # -*- coding: utf-8 -*- # from __future__ import unicode_literals AUTHOR = u'Sindhu S' SITENAME = u"Sindhu's blog" SITEURL = 'http://sindhus.bitbucket.org' TIMEZONE = 'Asia/Kolkata' DEFAULT_LANG = u'en' FEED_ALL_ATOM = 'feeds/all.atom.xml' CATEGORY_FEED_ATOM = '%s.atom.xml' TRANSLATION_FEED_ATOM = None RELATIVE_URLS = True LINKS = (('Pinterest', 'http://pinterest.com/sindhus/likes/'), ('Movies', 'https://www.facebook.com/sindhu.sundar.in/movies'), ('Ohloh', 'http://ohloh.net/accounts/sindhus'), ('Goodreads', 'https://www.goodreads.com/user/show/8856323-sindhu')) SOCIAL = (('Facebook', 'http://facebook.com/sindhu.sundar.in'), ('Twitter', 'http://twitter.com/sindhu')) PLUGIN_PATH="/home/sindhu/code/blog/plugins" PLUGINS = ['pelican_youtube'] THEME = "/home/sindhu/code/blog/themes/zurb-F5-basic" DISQUS_SITENAME = "sindhus" DEFAULT_PAGINATION = 8 USE_FOLDER_AS_CATEGORY = True STATIC_PATHS = ['images', 'pdfs']
My publishconf.py is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/env python # -*- coding: utf-8 -*- # from __future__ import unicode_literals import os import sys sys.path.append(os.curdir) from pelicanconf import * SITEURL = 'http://sindhus.bitbucket.org' RELATIVE_URLS = True FEED_ALL_ATOM = 'feeds/all.atom.xml' CATEGORY_FEED_ATOM = '%s.atom.xml' DELETE_OUTPUT_DIRECTORY = False DISQUS_SITENAME = "sindhus"
Disqus is a web service that will record comments of your blog readers for you. All you have to do is put your Disqus ID in your pelican blog. To see how it works, explore Disqus.com.
How to upload to github/bitbucket/provider?
Once you have created your blog on your computer, modified as per your liking, its time to put it on the Internet :-), the steps are:
- Create a repository with the name in the format of username.provider.org. For example, I have a repository with the name sindhus.bitbucket.org.
- In your computer, come to the folder called
outputwhere your blog was generated and create it to be a git repository with
- In this
git add remote <name> <address>. You can find this in github towards the right handside of the page. Its the same address you would used to clone this created repository. Keep in mind, if you use the HTTP link, then you would have enter your password, if you use the SSH link, then you would have to configure your SSH keys with github or bitbucket.So for example, I would add
git remote add bitbucket firstname.lastname@example.org:sindhus/sindhus.bitbucket.org.git.
- Now, you are ready to push your blog online with
git push <name> <branch>. For example, I would do:
git push bitbucket master.
- Once git pushes your work to the repository, your blog should be available online. So I after I upload I go to sindhus.bitbucket.org to check.