Migrated site to Pelican

Tue 19 May 2015 by Patrick Pierson

My website used to run on Wordpress. Don't take this as a Wordpress bashing post. I really liked Wordpress for what it did for me. I really didn't like how vunerable it is, but thats what you get with the most popular blogging platform. Everything is going towards DevOps though so I wanted to be able to build and deploy my own site in a fast and easy way. Pelican to the rescue. Using python I am able to build and deploy a site to S3.

To get started you will need python and either pip or easy_install (Windows):

pip install pelican
or
easy_install pelican

Once pelican is installed run:

pelican-quickstart

It will return with:

Welcome to pelican-quickstart v3.3.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? [.] 

This is asking where you want to create the site. The default is the current working directory. Most likely you will press enter here.

Next it will ask you:

> What will be the title of this web site? 

Enter the title of the website.

Next it will ask you:

> Who will be the author of this web site? 

Enter the name of the author.

Next it asks what language you will want to use, the default is english:

> What will be the default language of this web site? [en] 

Specify a URL for your website? The default is Yes:

> Do you want to specify a URL prefix? e.g., http://example.com   (Y/n) 

Next enter the URL:

> What is your URL prefix? (see above example; no trailing slash) 

If you wish to enable pages press enter next:

> Do you want to enable article pagination? (Y/n) 

The default is 10 articles per page, press enter to keep it:

> How many articles per page do you want? [10] 

To give yourself a more DevOps type of deployment press enter here. This will create a make file that will assist you in deployment:

> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) 

This setting is really cool. As you update the site it watches for changes and will use the develop_server script to rebuild on each change, press enter:

> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) 

Push your site via FTP? The default is no, press enter:

> Do you want to upload your website using FTP? (y/N) 

Push your site via SSH? The default is no, press enter:

> Do you want to upload your website using SSH? (y/N) 

Push your site via Dropbox? The default is no, press enter:

> Do you want to upload your website using Dropbox? (y/N) 

I initially pressed enter here and didnt setup S3. I might go back later and change this, I will add my deploys3.sh later in this post. Press enter:

> Do you want to upload your website using S3? (y/N) 

Push your site via Rackspace? The default is no, press enter:

> Do you want to upload your website using Rackspace Cloud Files? (y/N) 

At this point it will finish the quickstart.

Done. Your new project is available at /home/user/test

Once that is done run:

[user@user test]$ ./develop_server.sh start 8000

Since we havnt added any content the site will just have a blank default:

Starting up Pelican and pelican.server
DEBUG: Adding current directory to system path
DEBUG: Temporarily adding PLUGIN_PATH to system path
DEBUG: Restoring system path
DEBUG: Missing dependencies for asc
  --- AutoReload Mode: Monitoring `content`, `theme` and `settings` for changes. ---
DEBUG: Temporarily adding PLUGIN_PATH to system path
DEBUG: Restoring system path

-> Modified: theme, settings. re-generating...
WARNING: No valid files found in content.
DEBUG: template list: [u'!simple/archives.html', u'!simple/article.html', u'!simple/author.html', u'!simple/authors.html', u'!simple/base.html', u'!simple/categories.html', u'!simple/category.html', u'!simple/gosquared.html', u'!simple/index.html', u'!simple/page.html', u'!simple/pagination.html', u'!simple/tag.html', u'!simple/tags.html', u'!simple/translations.html', u'analytics.html', u'archives.html', u'article.html', u'article_infos.html', u'author.html', u'authors.html', u'base.html', u'categories.html', u'category.html', u'comments.html', u'disqus_script.html', u'github.html', u'gosquared.html', u'index.html', u'page.html', u'pagination.html', u'piwik.html', u'skribit_tab_script.html', u'skribit_widget_script.html', u'tag.html', u'taglist.html', u'tags.html', u'translations.html', u'twitter.html']
DEBUG: template list: [u'!simple/archives.html', u'!simple/article.html', u'!simple/author.html', u'!simple/authors.html', u'!simple/base.html', u'!simple/categories.html', u'!simple/category.html', u'!simple/gosquared.html', u'!simple/index.html', u'!simple/page.html', u'!simple/pagination.html', u'!simple/tag.html', u'!simple/tags.html', u'!simple/translations.html', u'analytics.html', u'archives.html', u'article.html', u'article_infos.html', u'author.html', u'authors.html', u'base.html', u'categories.html', u'category.html', u'comments.html', u'disqus_script.html', u'github.html', u'gosquared.html', u'index.html', u'page.html', u'pagination.html', u'piwik.html', u'skribit_tab_script.html', u'skribit_widget_script.html', u'tag.html', u'taglist.html', u'tags.html', u'translations.html', u'twitter.html']
DEBUG: template list: [u'!simple/archives.html', u'!simple/article.html', u'!simple/author.html', u'!simple/authors.html', u'!simple/base.html', u'!simple/categories.html', u'!simple/category.html', u'!simple/gosquared.html', u'!simple/index.html', u'!simple/page.html', u'!simple/pagination.html', u'!simple/tag.html', u'!simple/tags.html', u'!simple/translations.html', u'analytics.html', u'archives.html', u'article.html', u'article_infos.html', u'author.html', u'authors.html', u'base.html', u'categories.html', u'category.html', u'comments.html', u'disqus_script.html', u'github.html', u'gosquared.html', u'index.html', u'page.html', u'pagination.html', u'piwik.html', u'skribit_tab_script.html', u'skribit_widget_script.html', u'tag.html', u'taglist.html', u'tags.html', u'translations.html', u'twitter.html']
-> writing /home/izen/test/output/index.html
-> writing /home/izen/test/output/tags.html
-> writing /home/izen/test/output/categories.html
-> writing /home/izen/test/output/authors.html
-> writing /home/izen/test/output/archives.html
Done: Processed 0 articles and 0 pages in 0.17 seconds.
Pelican and pelican.server processes now running in background.

Open up your browser to:

http://localhost:8000

pelican-quickstart

When you are ready to create content start adding files to the content directory with the extention ".md". You will write it in Markdown syntax which also allow html formatting when needed. The default layout is as follows:

Title: Migrated site to Pelican
Date: 2015-05-19 21:59
Category: Pelican
Tags: Pelican, Python
Summary: Migrated from Wordpress to Pelican.

Test of the page in Markdown syntax.

Lastly I deploy my site to S3. I am having issues with the make file so I wrote a script to deploy to an S3 bucket.

1
2
3
4
#!/usr/bin/env bash
aws s3 rm --recursive s3://patrickpierson.us
echo 'Deleted'
aws s3 cp --recursive ./output/ s3://patrickpierson.us --acl public-read

Setup the bucket in S3 to work in a website mode by selecting "Static Website Hosting" and then "Enable website hosting" once there set the "Index Document" to "index.html" and you are done!

Thanks for reading!