Total Pageviews

Sunday 12 March 2017

搭建基于python2.7的静态博客程序-hyde

登陆linux vps.
先安装pip.

pip install hyde
(如果以后运行这样安装的hyde,遇错,那么我们可以如下来安装hyde:
git clone  https://github.com/hyde/hyde
cd hyde
pip install -r requirements.txt
python setup.py install)
hyde -s /usr/local/hyde-site create (此命令会在/usr/local/下,生成hyde-site目录)
cd /usr/local/hyde-site


root@AR:/usr/local/hyde-site# ls
README.markdown  content  info.yaml  layout  site.yaml
root@AR:/usr/local/hyde-site# hyde gen -r
(此即生成/更新静态网站的根目录的命令)
root@AR:/usr/local/hyde-site# ls
README.markdown  content  deploy  info.yaml  layout  site.yaml
(生成了deploy目录)
root@AR:/usr/local/hyde-site# cd deploy
root@AR:/usr/local/hyde-site/deploy# ls
about.html  blog  index.html  media  portfolio
(可见/usr/local/hyde-site/deploy就是静态网站的根目录)
root@AR:/usr/local/hyde-site/deploy#

新建源帖:
root@AR:/usr/local/hyde-site/deploy# cd ../content/blog
root@AR:/usr/local/hyde-site/content/blog# nano test-1.html
root@AR:/usr/local/hyde-site/content/blog# cat test-1.html
---
title: 测试1
description: >
    点击标题,看全文
created: !!timestamp '2017-03-12 14:07:00'
tags:
    - misc1
    - misc2
---

这是测试1.

看看如何?

root@AR:/usr/local/hyde-site/content/blog# cd ../..
root@AR:/usr/local/hyde-site# hyde gen -r

不过,发表的中文帖子会显示乱码。解决办法:
root@AR:/usr/local/hyde-site# cd layout
root@AR:/usr/local/hyde-site/layout# nano base.j2
(在这一行<meta charset="{{ resource.meta.charset }}">的下一行加上:
<meta charset=utf-8>
root@AR:/usr/local/hyde-site/layout# cd ..
root@AR:/usr/local/hyde-site# hyde gen -r

演示网站:http://hyde.bright.biz.st/, http://hyde.bright.biz.st/blog/
项目地址:
https://github.com/hyde/hyde
http://hyde.github.io/
http://hyde.github.io/commands
http://hyde.github.io/templates/

以前其实写过这个博客程序的搭建文章:
http://briteming.blogspot.com/2013/12/linux-vpspythonvirtualenvpython27-hyde.html
---------------

cd /usr/local
git clone https://github.com/jd/julien.danjou.info
cd  julien.danjou.info

root@AR:/usr/local/julien.danjou.info# ls
Makefile   bin  layout     site.yaml
README.md  content   requirements.txt
root@AR:/usr/local/julien.danjou.info# hyde gen -r
root@AR:/usr/local/julien.danjou.info# ls
Makefile   bin        deploy    layout          site.yaml
README.md  content    requirements.txt
root@AR:/usr/local/julien.danjou.info# cd deploy
root@AR:/usr/local/julien.danjou.info/deploy# ls
about  blog  books  projects  sitemap.xml  talks
(没有index.html;不过在发表帖子后,可以新建index.html,内容为:
<meta http-equiv=refresh content='0;url=/blog'> ,所以/usr/local/julien.danjou.info/deploy目录就是
静态网站的根目录)
root@AR:/usr/local/julien.danjou.info/deploy#

新建源帖:
root@AR:/usr/local/julien.danjou.info/deploy# cd ../content/blog
root@AR:/usr/local/julien.danjou.info/content/blog#
root@AR:/usr/local/julien.danjou.info/content/blog# ls
2007  2009  2011  2013    2015  2017      index.xml  tags
2008  2010  2012  2014    2016  index.html  meta.yaml
root@AR:/usr/local/julien.danjou.info/content/blog# cd 2017
root@AR:/usr/local/julien.danjou.info/content/blog/2017# nano test-1
root@AR:/usr/local/julien.danjou.info/content/blog/2017# cat test-1
---
title: "测试1"
created: !!timestamp '2017-03-12 18:36:00'
tags:
    - misc1
    - misc2
---

这是测试1.

看看如何?

root@AR:/usr/local/julien.danjou.info/content/blog/2017# cd /usr/local/julien.danjou.info
root@AR:/usr/local/julien.danjou.info# hyde gen -r
root@AR:/usr/local/julien.danjou.info# cd deploy
root@AR:/usr/local/julien.danjou.info/deploy# nano index.html
root@AR:/usr/local/julien.danjou.info/deploy# cat index.html
<meta http-equiv=refresh content='0;url=/blog'>
root@AR:/usr/local/julien.danjou.info/deploy#

演示网站:http://jdi.bright.biz.st,http://jdi.bright.biz.st/blog/
项目地址:https://github.com/jd/julien.danjou.info

No comments:

Post a Comment