From charlesreid1

No edit summary
Line 138: Line 138:
theme
theme
</pre>
</pre>
=Pelican Themes=
You can create your own themes with Pelican, and this is where Pelican becomes a tool for organizing static web content that is a lot like Ruby's Jekyll.

Revision as of 01:08, 12 January 2015

Starting with Pelican

Begin by using pip to install pelican and markdown:

pip install pelican markdown

or install via Pelican Github repo:

Pelican documentation is here:

and the Pelican quickstart guide is here:

Using Pelican with Github Project Page

If you want to use pelican to manage a github project page, start by creating a "source code" bundle for your Pelican site in the master branch. This will deploy static content to the gh-pages branch, which is what shows up when you visit http://username.githubpages.io/project-name.

Starting Your Pelican Site

Start in the master branch of your project. Here, I'll use my Words, Words, Words project as an example.

$ pwd
/Users/charles/codes/wordswordswords/pelican

Now I create the site with the pelican-quickstart command, answering some questions from Pelican:

$ pelican-quickstart

Welcome to pelican-quickstart v3.5.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? Words, Words, Words
> Who will be the author of this web site? CR
> 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) y
> How many articles per page do you want? [10]
> 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) 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 /Users/charles/codes/wordswordswords/pelican


Creating Markdown Content for Pelican Site

Once your Pelican site has been created, we can create markdown content by putting markdown files into the content/ directory. For example,

Title: An Article
Date: 2014-12-21 10:20
Category: Essay

This is just an ordinary article.

We can then generate static content from the markdown files by running the pelican content command:

$ pelican content
Done: Processed 1 article(s), 0 draft(s) and 0 page(s) in 0.33 seconds.

and preview the site by going into the output/ directory and running a simple HTTP server with Python:

$ cd output/

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

Then you can visit http://localhost:8000 to see the site preview locally.

The next steps involve connecting this output folder to the Github branch that is pointed to by our Github Project page's live hosted static content. That way, we can type pelican content to generate content, and then use git push to push the freshly-generated content to the live Github Pages project site.

Connecting Pelican Output to gh-pages Branch

The next step will allow you to deploy content directly to the live gh-pages branch, using Pelican.

In the project/pelican directory (in my case, wordswordswords/pelican):

$ ls 
Makefile
cache
content
develop_server.sh
fabfile.py
output
pelicanconf.py
pelicanconf.pyc
publishconf.py

We will first remove the output/ directory. Then we will check out a copy of the gh-pages branch to the output/ directory. Now, when we type pelican content, it will generate the static content directly in the gh-pages branch!

$ rm -rf output/

$ git clone -b gh-pages https://github.com/charlesreid1/wordswordswords.git output/
Cloning into 'output'...
remote: Counting objects: 40, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 40 (delta 13), reused 29 (delta 3)
Unpacking objects: 100% (40/40), done.
Checking connectivity... done

$ pelican content
Done: Processed 1 article(s), 0 draft(s) and 0 page(s) in 0.31 seconds.

$ ls output/
archives.html
author
authors.html
categories.html
category
i-am-a-dummy.html
index.html
tags.html
theme

Pelican Themes

You can create your own themes with Pelican, and this is where Pelican becomes a tool for organizing static web content that is a lot like Ruby's Jekyll.