使用pelican搭建个人博客
pelican介绍
Pelican是一个用Python语言编写的静态网站生成器,支持使用restructuredText和Markdown写文章,配置灵活,扩展性强
pelican安装
1$ sudo pip install pelican
安装markdown
1$ sudo pip install markdown
pelican使用
工具准备好了,接下来就开始使用
1$ cd git 2$ mkdir pelican #建立一个文件夹(位置和名称随意,自己记得就行) 3$ cd pelican 4$ pelican-quickstart
显示 (也可以直接回车默认)
1Welcome to pelican-quickstart v3.4.0. 2 3This script will help you create a new Pelican-based website. 4 5Please answer the following questions so this script can generate the files 6needed by Pelican. 7 8 9> Where do you want to create your new web site? [.] 10> What will be the title of this web site? HonMaple 11> Who will be the author of this web site? honmaple 12> What will be the default language of this web site? [en] zh 13> Do you want to specify a URL prefix? e.g., http://example.com (Y/n) 14> What is your URL prefix? (see above example; no trailing slash) http://honmaple.github.io 15> Do you want to enable article pagination? (Y/n) 16> How many articles per page do you want? [10] 17> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) 18> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) 19> Do you want to upload your website using FTP? (y/N) 20> Do you want to upload your website using SSH? (y/N) 21> Do you want to upload your website using Dropbox? (y/N) 22> Do you want to upload your website using S3? (y/N) 23> Do you want to upload your website using Rackspace Cloud Files? (y/N) 24> Do you want to upload your website using GitHub Pages? (y/N) Y 25> Is this your personal page (username.github.io)? (y/N) Y 26Done. Your new project is available at /home/git/pelican
接下来要设置pelicanconf.py和publishconf.py
具体可以看官方帮助文档或者参考我的配置
查看目录
pelican/
├── content
├── output
├── develop_server.sh
├── fabfile.py
├── Makefile
├── pelicanconf.py # Main settings file
└── publishconf.py # Settings to use when ready to publish
现在可以开始写第一篇文章了
1$ cd content 2$ mkdir articles pages extra impages 3$ cd articles 4$ vim hello.md
在文件开头输入下列内容
1Title: 文章标题 2Author: 作者 3Date: 2015-10-15 4Category: 文章类别 5Tags: 标签 6Summary: 概要内容 7 8具体内容
保存退出后输入
1$ cd ../../ #进入pelican文件夹下 2$ make html
可以看实际效果
1$ google-chrome-stable output/index.html
提交内容
编辑好内容并且make html后需要将内容push到github
1$ cd output/ 2$ git init 3$ git remote add origin [email protected]:honmaple/honmaple.github.io.git #关联远程仓库 4$ git add . 5$ git commit -m "My first blog by pelican"
过几分钟后就可以看到内容了
