在Linux
环境下搭建,采用ubuntu
,使用其它发行版过程基本相同。html
Github
,注册和配置SSH
密钥过程help page写得很清楚。十分钟后在username.github.io
页面就已经生成了一个页面。访问该网址便可看到。python
在这里我没有用Jekyll
由于它是Ruby
写的对它没什么兴趣。因此我采用Python
编写的Pelican
。git
Pelican
是一套开源的使用Python
编写的博客静态生成, 能够添加文章和和建立页面, 可使用MarkDown
reStructuredText
和 AsiiDoc
的格式来抒写, 同时使用 Disqus
评论系统, 支持 RSS
和Atom
输出, 插件, 主题, 代码高亮等功能, 采用Jajin2
模板引擎, 能够很容易的更改模板github
安装Pelican
有不少种方法。一种使用python
的包管理器pip
进行安装。web
$sudo apt-get install python-pip $sudo pip install pelican $sudo pip install markdown
另外一种就是从github
上克隆Pelican
。bootstrap
git clone git://github.com/getpelican/pelican.git cd pelican python setup.py install
mkdir blog cd blog pelican-quickstart
在回答一系列问题事后你的博客就建成的, 主要生成下列文件:
生成的目录结构:ubuntu
blog/ ├── content │ └── *.md # markdown文件 ├── output # 默认的输出目录 ├── develop_server.sh ├── Makefile ├── pelicanconf.py # 主配置文件 └── publishconf.py
在 content
目录新建一个 test.md
文件, 填入一下内容:浏览器
Title: 文章标题 Date: 2013-04-18 Category: 文章类别 Tag: 标签1, 标签2 这里是内容
而后执行服务器
make html
生成了html
。而后执行markdown
./develop_server.sh start
开启一个测试服务器, 这会在本地 8000 端口创建一个测试web服务器, 可使用浏览器打开:http://localhost:8000
来访问这个测试服务器, 而后就能够欣赏到你的博客了
这里以建立 About页面为例
在content
目录建立pages目录
mkdir content/pages
而后建立About.md
并填入下面内容
Title: About Me Date: 2013-04-18 About me content
执行 make html
生成html
, 而后打开http://localhost:8000
查看效果
使用Disqus做为评论系统,注册账号后直接在pelicanconf.conf中添加:
DISQUS_SITENAME = your_shortname
而后执行
make html
使用浏览器打开:http://localhost:8000
来查看效果
安装主题:
Pelican自己提供不少主题可供选择,能够从github
上clone
下来
git clone https://github.com/getpelican/pelican-themes.git cd pelican-themes pelican-themes -i bootstrap2
其中bootstrap2
是选择使用的主题,pelican主题的Github目录下几乎每一个都提供了预览.
而后,在配置文件pelicanconf.py
中添加:
THEME = u"bootstrap2'
从新make,就生成了带有选定主题的页面。
Pelican
一开始是将插件内置的, 可是新版本 Pelican
将插件隔离了出来, 因此咱们要到github上 克隆一份新的插件, 在博客目录执行
git clone git://github.com/getpelican/pelican-plugins.git
如今咱们博客目录就新添了一个 pelican-plugins
目录, 咱们已配置sitemap插件为例, sitemap插件能够生成 sitemap.xml 供搜索引擎使用
在pelicanconf.py
配置文件里加上以下项:
PLUGIN_PATH = u"pelican-plugins" PLUGINS = ["sitemap"]
配置sitemap 插件
SITEMAP = { "format": "xml", "priorities": { "articles": 0.7, "indexes": 0.5, "pages": 0.3, }, "changefreqs": { "articles": "monthly", "indexes": "daily", "pages": "monthly", } }
而后再执行
make html
打开浏览器请求 http://localhost:8000/sitemap.xml
便可看到生成的 Sitemap 了
去Google Analytics申请帐号,记下跟踪ID。 在pelicanconf.py添加
GOOGLE_ANALYTICS = 跟踪ID
在Google Webmasters上注册便可。
这个就是Google站长工具,使用它的目的是为了让博客被Google更好的收录,好比手动让Googlebot抓取、提交Robots、更新Sitemap等等,各方面完爆百度站长工具。
最后在你的output
文件夹内
git init git add . git commit -m 'first commit' git remote add origin git@github.com:yourname/yourname.github.io.git git push -u origin master
这样就大功告成了!