Fork me on GitHub
 周六 11 十一月 2017
 RaoYi

pelican for windows踩坑

STEP1、安装

pip install pelican
pip install markdown(似乎不是必要的,但我装了)

STEP2、为防止杂乱,建议给专门的文件夹,如:

C:\blog\

STEP3、创建框架

cd blog
pelican-quickstart

STEP4、根据提示进行设置

> Where do you want to create your new web site? [.]
> What will be the title of this web site? RaoYi.net
> Who will be the author of this web site? RaoYi
> What will be the default language of this web site? [Chinese (Simplified)]
> Do you want to specify a URL prefix? e.g., http://example.com   (Y/n)
> What is your URL prefix? (see above example; no trailing slash) raoyi.net
> Do you want to enable article pagination? (Y/n)
> How many articles per page do you want? [10]
> What is your time zone? [Europe/Paris] Asia/Shanghai
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n)
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)
> Do you want to upload your website using FTP? (y/N)
> Do you want to upload your website using SSH? (y/N)
> Do you want to upload your website using Dropbox? (y/N)
> Do you want to upload your website using S3? (y/N)
> Do you want to upload your website using Rackspace Cloud Files? (y/N)
> Do you want to upload your website using GitHub Pages? (y/N)
Done. Your new project is available at C:\blog

STEP5、文件结构说明

/content/   #写的文章放这里
/output/    #生成的输出文件(发布的内容)
develop_server.sh
Makefile    #方便管理网站的Makefile
pelicanconf.py  #主配置文件
publishconf.py

STEP6、写文章

放在content目录中,命名为.md文件,下面举个栗子

Title: 这里写标题
Date: 2017-11-18
Category: 所属分类
Tags: 所属标签
Slug: about #固定的URL

这里是文章内容,按照markdown格式

STEP7、添加页面

在content目录下创建一个pages目录,在里面写.md文件

STEP8、生成网页,在之前创建的C:\blog\目录下执行

pelican content #默认状态下可以简化成 pelican

STEP9、启动server环境,在生成的output目录下执行

python -m pelican.server
Ctrl+C结束服务

STEP10、本地浏览

浏览器打开:127.0.0.1:8000

STEP11、发布网站到GitHub

把output目录中的内容上传到GitHub中名为username.github.io的repository

STEP12、在GitHub上自定义域名

在username.github.io中添加CNAME文件(无扩展名,大写),内容为网址,如:raoyi.net