Monday, December 30, 2013

Setup Pelican

[Pelican] is a static site generator, written in Python. It allows you write your content in Markdown and reStructuredText. It uses
Here are the steps to setup a hello world [Pelican].

1. Install pip and virtualenv

It is highly recommended to use a virtualenv to create isolated python environment and use pip to manage your packages.
You could refer to my post [Setup Pip and Virtualenv] for instructions to install them.

2. Create a virtual environment

Once you installed virtualenv, you could activate your virtual environment by executing the following command.

virtualenv pelican
cd pelican
. bin/activate

About the last line, if you are using Fish shell, you may need to use . bin/activate.fish instead.

3. Install required packages

pip install pelican markdown

4. Create pelican configuration file

There is a quick start program pelican-quickstart than can help you create a pelican configuration file quickly.
The program will ask you several questions to gather the information needed.

> Where do you want to create your new web site? [.] 
> What will be the title of this web site? Hello World Blog
> Who will be the author of this web site? Your Name
> 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) Y
> What is your URL prefix? (see above example; no trailing slash) http://hello-world-blog.com
> Do you want to enable article pagination? (Y/n) Y
> How many articles per page do you want? [10] 8
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) Y
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) Y
> 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)

5. Draft the first post

Create a markdown file in content folder.

mkdir content
vim content/the-first-post.md

And paste the following content into it.

Title: Hello World
Date: 2013-10-25
Category: Misc

# Hello World

6. Generate HTML files

After the following command succeeded, HTML files will be generated in output folder.

pelican content -s pelicanconf.py -o output

7. Preview the blog

You could start a local HTTP server by running the following command,
and then you can preview your site at http://localhost:8000

cd output && python -m SimpleHTTPServer

No comments:

Post a Comment