Total Pageviews

Saturday, 27 August 2016

安装基于go的静态博客程序pugo

首先安装go1.4版。(从官网下载go1.4版 ,解压到/usr/local,这样/usr/local/下会生成go目录)
cd /usr/local/go/
mkdir gospace
cd gospace
export GOPATH=`pwd`

root@AR:/usr/local/go/gospace# /usr/local/go/bin/go get github.com/go-xiaohei/pugo
(参见http://pugo.io/en/docs/dl-compile)
root@AR:/usr/local/go/gospace# ls bin
gor  peach  pugo
root@AR:/usr/local/go/gospace# 
(/usr/local/go/gospace/bin/里面出现了可执行文件pugo,说明pugo安装成功)
root@AR:/usr/local/go/gospace# cd /usr/local/
root@AR:/usr/local# mkdir pugo-site
root@AR:/usr/local# cd pugo-site
root@AR:/usr/local/pugo-site# /usr/local/go/gospace/bin/pugo new site (此命令会在当前目录下生成pugo网站的目录结构,具体就是生成了2个目录:source,theme)
root@AR:/usr/local/pugo-site# ls
source  theme
root@AR:/usr/local/pugo-site# /usr/local/go/gospace/bin/pugo build(此命令就是生成/更新静态网站的命令)
root@AR:/usr/local/pugo-site# ls
dest  source  theme
(生成了dest目录)
root@AR:/usr/local/pugo-site# cd dest
root@AR:/usr/local/pugo-site/dest# ls
2016     archive.html  favicon.ico  index.html  media  robots.txt   tags
about.html  css   feed.xml     js   posts  sitemap.xml
root@AR:/usr/local/pugo-site/dest# 
(可见/usr/local/pugo-site/dest/就是静态网站的根目录)

新建源贴:
root@AR:/usr/local/pugo-site/dest# cd ..
root@AR:/usr/local/pugo-site# ls
dest  source  theme
root@AR:/usr/local/pugo-site# cd source
root@AR:/usr/local/pugo-site/source# ls
favicon.ico  lang  media  meta.toml  page  post  robots.txt
root@AR:/usr/local/pugo-site/source# cd post
root@AR:/usr/local/pugo-site/source/post# 
root@AR:/usr/local/pugo-site/source/post# ls
welcome.md
root@AR:/usr/local/pugo-site/source/post# nano test-1.md  
(按照welcome.md的格式,新建源贴test-1.md  ,内容如下:
```toml
# post title, required
title = "测试1"

# post slug, use to build permalink and url, required
slug = "test-1"

# post description, show in header meta
desc = "welcome to try pugo site generator"

# post created time, support
# 2015-11-28, 2015-11-28 12:28, 2015-11-28 12:28:38
date = "2016-08-28 09:43:20"

# post updated time, optional
# if null, use created time
# update_date = "2016-03-25 12:20:20"

# author identifier, reference to meta [[author]], required
author = "brite"

# thumbnails to the post
thumb = "@media/golang.png"

# tags, optional
tags = ["misc"]
```

这是测试1.
root@AR:/usr/local/pugo-site/source/post# cd ../..
root@AR:/usr/local/pugo-site# /usr/local/go/gospace/bin/pugo build

演示网站:http://surmount.biz.st:32257,http://pg.smt.biz.st(这是用编译的pugo建立的网站)
http://pg2.smt.biz.st(这是用下载的可执行文件pugo建立的网站),你对比一下,2个网站的第二页是不同的。
项目地址:https://github.com/go-xiaohei/pugo,(作者提供了可执行文件下载:
32位版-https://github.com/go-xiaohei/pugo/releases/download/0.10.0/linux_386.zip
64位版-https://github.com/go-xiaohei/pugo/releases/download/0.10.0/linux_amd64.zip
你可以去下载后,解压,即可使用。)
http://pugo.io/en/docs/dl-compile

相关帖子:http://briteming.blogspot.com/2013/08/linux-vps-gor.html