A tutorial on using Pelican to build blogs on GitHub pages _python

Source: Internet
Author: User
Tags mkdir 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
    • Support for Atom and RSS output

These features are great love, fully meet my basic needs of the blog system, and then with Free unlimited GitHub Pages, all near perfect.
Install Pelican

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

Creating a Pelican Virtual environment

Virtualenv pelicanenv--distribute
pelicanenv\scripts\activate

Install Pelican

Pip Install Pelican

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

Pip Install Markdown

Create a Blog

Create a Blog directory

mkdir myblog
CD MyBlog

Create a Blog quickly

Pelican-quickstart

According to the prompts to enter the appropriate configuration items step-by-step, do not know how to set the acceptance defaults can be followed by editing the pelicanconf.py file to change the configuration.

The following is the generated directory structure:

Copy Code code as follows:
myblog/
├──content # Store the input source file
│└── (pages) # Store a manually created static page
Output file generated by ├──output #
├──DEVELOP_SERVER.SH # Easy to open test server
├──makefile # Easy to manage blog Makefile
├──pelicanconf.py # master configuration file
└──publishconf.py # The configuration file used when publishing

Writing articles

Write an article in the content directory with markdown syntax

Copy 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 for my Super blog post.

Build Page

Make HTML

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

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

Py=python pelican=pelican pelicanopts= basedir=$ (CurDir) inputdir=$ (BASEDIR)/content outputdir=$ (BASEDIR)/output githubdir=$ (BASEDIR)/togithub conffile=$ (BASEDIR)/pelicanconf.py publishconf=$ (BASEDIR)/publishconf.py Help: @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 (RE) 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://l 
 ocalhost:8000 ' @echo ' make devserver start/restart develop_server.sh ' @echo ' make stopserver stop local server ' @echo ' make publish generate using production settings ' @echo ' all:html Html:clean $ (outputdir) /index.html Cptogithub Clean: @echO-n ' cleaning. ... ' "The ... ' @rm-fr $ (outputdir) @mkdir $ (outputdir) @echo ' Done ' $ (outputdir)/%.html:, A., ..... $ (PELICAN) $ (inputdir)-O $ (outputdir)-S $ (conffile) $ (pelicanopts) Cptogithub: @echo-n ' copying ..... ... ' @cp-fr $ (outputdir)/* $ (Githubdir) @echo ' Done ' Regenerate:clean $ (PELICAN)-R $ (inputdir)-O $ (outputdir -S $ (conffile) $ (pelicanopts) SERVE:CD $ (OutputDir) && $ (PY)-M pelican.server devserver: $ (BASEDIR)/develo p_server.sh restart stopserver:kill-9 ' cat pelican.pid ' kill-9 ' cat srv.pid ' @echo ' Stopped Pelican and Simplehttps

Erver processes running in background. ' Publish: $ (PELICAN) $ (inputdir)-O $ (outputdir)-S $ (publishconf) $ (pelicanopts).

 Phony:help all HTML clean cptogithub regenerate serve devserver stopserver

Create GitHub Pages

GitHub pages are divided into two types, one is the project page, the other is the user page, and each user ID can only be created. Both can be used to host pelican blogs, as an example of a user page.

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

After the creation is successful, you can push the generated page to GitHub.

CD output
git init
git Add.
ter

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

Under the root directory of repo, create a new text file called CNAME that contains the domain name you want to bind, such as top-level domain example.com or level two domain xxx.example.com.

If the top-level domain name is bound, DNS creates a new a record, pointing to 204.232.175.78.

If you are binding a level two domain name, DNS creates 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 point 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 done

Please refer to Pelican official documentation for other content. I am translating this document, which is just beginning and progressing slowly. Please click on the Pelican document to visit the Chinese version and welcome your 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.