首先使用pip安装pelican和markdown
pip install pelican markdown
然后创建目录
mkdir my_blog
接着进入目录cd my_blog
,执行pelican-quickstart
,当前目录内就会生成默认配置好的文件
pelicanconf.py是博客的配置文件:
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
AUTHOR = u\'printR\'
SITENAME = u\"catmelo\"
SITEURL = \'http://www.cnblogs.com/catmelo/\'
PATH = \'content\'
TIMEZONE = \'Asia/Shanghai\'
DATE_FORMATS = {\'zh\':\'%Y-%m-%d %H:%M\'}
DELETE_OUTPUT_DIRECTORY = False
DEFAULT_LANG = u\'zh\'
THEME = \'pelican-themes/pelican-bootstrap3\'
PLUGIN_PATHS = [\"plugins\", \"pelican-plugins\"]
PLUGINS = [\'tag_cloud\', \'related_posts\', \'pelican-toc\']
USE_FOLDER_AS_CATEGORY = True
#DEFAULT_CATEGORY = u\'文章\'
SITELOGO = \'images/logo.png\'
FAVICON = \'images/logo.png\'
SITELOGO_SIZE = 14
ARTICLE_URL = \'posts/{category}/{slug}/\'
ARTICLE_SAVE_AS = \'posts/{category}/{slug}/index.html\'
PAGE_URL = \'pages/{slug}/\'
PAGE_SAVE_AS = \'pages/{slug}/index.html\'
MD_EXTENSIONS = [\'codehilite(css_class=highlight)\',\'extra\']
STATIC_PATHS = [\'images\', \'extra\']
EXTRA_PATH_METADATA = {\'extra/CNAME\': {\'path\': \'CNAME\'},}
DISPLAY_ARTICLE_INFO_ON_INDEX = True
DISPLAY_TAGS_INLINE = False
DISPLAY_RECENT_POSTS_ON_SIDEBAR = True
SHOW_ARTICLE_CATEGORY = True
SHOW_DATE_MODIFIED = True
RELATED_POSTS_TEXT = u\'相关文章\'
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
# Blogroll
LINKS = ((u\'Github\', \'http://github.com\'),)
# Social widget
SOCIAL = ((\'Github\', \'http://github.com\'),)
DEFAULT_PAGINATION = 10
# Uncomment following line if you want document-relative URLs when developing
#RELATIVE_URLS = True
#pelican_toc插件配置
TOC = {
\'TOC_HEADERS\' : \'^h[3-6]\', # What headers should be included in the generated toc
# Expected format is a regular expression
\'TOC_RUN\' : \'true\' # Default value for toc generation, if it does not evaluate
# to \'true\' no toc will be generated
}
在Makefile文件里添加upload命令,方便上传到github:
...
html:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
upload:
cd $(OUTPUTDIR) && git add -A && git commit -am \"update blog\" && git push origin master
...
获取主题:git clone git://github.com/getpelican/pelican-themes.git
获取插件:git clone git://github.com/getpelican/pelican-plugins.git
修改pelicanconf.py文件,使主题和插件生效:
THEME = \'pelican-themes/pelican-bootstrap3\' #直接指定主题目录
PLUGIN_PATHS = [\"plugins\", \"pelican-plugins\"] #pelican-plugins为插件总目录
PLUGINS = [\'tag_cloud\', \'related_posts\'] #插件总目录里的插件(文件夹)名
在content/extra/
内添加CNAME文件,CNAME里只需写入一行域名,例如:github.com
修改pelianconf.py:
STATIC_PATHS = [\'extra\']
EXTRA_PATH_METADATA = {\'extra/CNAME\': {\'path\': \'CNAME\'},}
cd output
git init
git remote add origin https://github.com/your_name/your_blog.git
git add -A
git commit -am \"update blog\"
git pull origin master
git push origin master
以后更新网站只需要执行:
cd my_blog
make html
make upload
修改pelicanconf.py:
STATIC_PATHS = [\'images\', \'extra\']
SITELOGO = \'images/logo.png\'
FAVICON = \'images/logo.png\'
SITELOGO_SIZE = 14
把图标logo.png
放进content/images/
里即可
上一篇:jieba分词学习笔记(三)
下一篇:python编码的意义