Tutorial on using Pelican to build a blog on GitHub pages

Source: Internet
Author: User
Tags disqus comments virtual environment virtualenv
Pelican Introduction

First look at some of the main features of Pelican:

    • Python implementation, open source
    • Output static pages for easy hosting
    • Support themes, using the Jajin2 template engine
    • Support Code Syntax highlighting
    • Supports Restructuredtext, Markdown, asciidoc formats
    • Support Disqus Comments
    • Supports Atom and RSS output

These features are big love, fully meet my basic needs of the blog system, and with free unlimited GitHub Pages, everything is almost perfect.
Installing Pelican

Before starting, please install the Python environment, support 2.7.X and 3.3+, for convenience, and then put on distribute, Pip, virtualenv. (Note: My operating system is: Windows 7)

Create a Pelican Virtual environment

Virtualenv pelicanenv--distributepelicanenv\scripts\activate

Installing Pelican

Pip Install Pelican

If you use Markdown to write articles, you also need to install the Markdown Library

Pip Install Markdown

Create a Blog

Create a Blog directory

mkdir MYBLOGCD MyBlog

Create a Blog quickly

Pelican-quickstart

Follow the prompts step by step to enter the appropriate configuration items, do not know how to set the Accept default, and subsequently you can change the configuration by editing the pelicanconf.py file.

The following is the resulting directory structure:

Copy the Code code as follows:

myblog/
├──content # Storing the input source files
│└── (pages) # Store manually created static pages
├──output # generated output file
├──DEVELOP_SERVER.SH # Easy to open test server
├──makefile # Easy to manage blog Makefile
├──pelicanconf.py # Master Config file
└──publishconf.py # configuration file used when publishing

Write an article

Write an article in the content directory using Markdown syntax

Copy the Code code as follows:

Title:my Super Title
date:2010-12-03 10:20
Category:python
Tags:pelican, publishing
Slug:my-super-post
Author:alexis Metaireau
Summary:short version for index and feeds

This is the content of my Super blog post.

Build Page

Make HTML

You can now view the generated HTML file in the output directory.

Since my operating system is windows, I have made some changes to makefile.

py=pythonpelican=pelicanpelicanopts=basedir=$ (CURDIR) inputdir=$ (BASEDIR)/contentoutputdir=$ (BASEDIR)/ outputgithubdir=$ (BASEDIR)/togithubconffile=$ (BASEDIR)/pelicanconf.pypublishconf=$ (BASEDIR)/publishconf.pyhelp             : @echo ' @echo ' Makefile for a Pelican Web site ' @echo ' @echo ' Usage: ' @echo ' make help print help information ' @echo ' make all (re) generate the Web site ' @echo ' make HTML (r e) Generate the Web site ' @echo ' make clean Remove the generated files ' @echo ' make Cptogithub copy output files To Githubdir ' @echo ' make regenerate regenerate files upon modification ' @echo ' make serve serve site at Http://loc alhost:8000 ' @echo ' make devserver start/restart develop_server.sh ' @echo ' make stopserver stop local server ' @ec Ho ' make publish generate using production settings ' @echo ' All:htmlhtml:clean $ (OUTPUTDIR)/index.htm L Cptogithubclean: @echo-n ' cleaning .............. ' @rm-fr $ (OUTPUTDIR) @mkdir $ (OUTPUTDIR) @echo ' Done ' $ (OUTPUTDIR)/%.html: $ (PELICAN) $ (inputdir)-O $ (OUTPUTDIR )-S $ (conffile) $ (pelicanopts) Cptogithub: @echo-n ' Copying .... ' @cp-fr $ (OUTPUTDIR)//$ (for the.). '. '. ' Githubdir) @echo ' Done ' Regenerate:clean $ (PELICAN)-R $ (inputdir)-O $ (OUTPUTDIR)-S $ (conffile) $ (pelicanopts) SERVE:CD $ (OUTPUTDIR) && $ (PY)-M Pelican.serverdevserver: $ (BASEDIR)/develop_server.sh restartstopserver:kill-9 ' cat Pelican.pid ' kill-9 ' cat srv.pid ' @echo ' Stopped Pelican and Simplehttpserver processes running in background. ' Publish: $ (PELICAN) $ (inputdir)-O $ (OUTPUTDIR)-S $ (publishconf) $ (pelicanopts). Phony:help all HTML clean cptogithub regenerate serve devserver stopserver publish

Create a GitHub Pages

There are two types of GitHub pages, one is the project page, one can create multiple, the other is a user page, and each user ID can only create one. Both can be used to host the Pelican blog, which takes the user page as an example.

Click here to create a new repository,repository name can be Xxx.github.io or xxx.github.com, where xxx is your user ID.

Once created, you can push the generated page to GitHub.

CD outputgit initgit add git commit-m "first commit" git remote add Origin https://github.com/xxx/xxx.github.io.gitgit PU Sh-u Origin Master

You can now visit your blog via Xxx.github.io or xxx.github.com.
Domain Binding

Under Repo's root directory, create a new text file named CNAME that writes the domain name you want to bind to, such as a top-level domain name example.com or a level two domain name xxx.example.com.

If you are binding a top-level domain, DNS creates a new a record, pointing to 204.232.175.78.

If you are binding a two-level domain name, DNS will create a new CNAME record, pointing to Xxx.github.io or xxx.github.com.

Take my example:

CNAME file

Www.dongxf.com

Set on Dnspod

Enter the following link in the browser address bar to jump to http://www.dongxf.com/

http://dongxf.com/
http://www.dongxf.com/
http://blog.dongxf.com/
http://dongdxf.github.io/
http://dongdxf.github.com/

Matters not yet done

Please refer to the Pelican Official documentation for additional information. I am translating this document, just beginning, slow progress. Please click on the Pelican document in the Chinese version of the visit, welcome to provide valuable comments and suggestions.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.