hugo

概览

Hugo是由Go语言实现的静态网站生成器。简单、易用、高效、易扩展、快速部署。

安装

hugo 在linux, windows, mac上都有一个简单的二进制文件下载即可

######################################## Mac OS X ########################################
wget http://fs.as4k.com:7778/chfs/shared/soft/hugo_0.59.1_macOS-64bit.tar.gz
tar xf hugo_0.59.1_macOS-64bit.tar.gz
sudo -i
echo $PATH
cp -a hugo /usr/local/bin

下载地址  https://github.com/gohugoio/hugo/releases

通用

######################################## Build static pages ##############################################
hugo -D
The command hugo renders your site into public/ dir and is ready to be deployed to your web server

Hugo for Mac OS X

ndpss-MacBook-Pro:xdocs ndps$ hugo version
Hugo Static Site Generator v0.59.1-D5DAB232 darwin/amd64 BuildDate: 2019-10-31T15:21:24Z

hugo server --help

cd /Users/ndps/ndocs/xdocs
hugo server --bind "0.0.0.0" --port 1313 --theme hugo-theme-learn

-t, --theme strings          themes to use (located in /themes/THEMENAME/)

ndpss-MacBook-Pro:xdocs ndps$ pwd
/Users/ndps/ndocs/xdocs
ndpss-MacBook-Pro:xdocs ndps$ ls
README.md	archetypes	config.toml	config.toml.bak	content		image		layouts		public		resources	static		themes

Hugo for Windows

/mnt/d/xdld/hugo_0.62.2_Linux-64bit/hugo  new posts/my-first-post.md
cat /etc/profile
export PATH=/mnt/d/xdld/hugo_0.62.2_Linux-64bit:$PATH
hugo server -D
http://localhost:1313/
as4k@DESKTOP-PM5KOT8:/mnt/c/Users/xpc$ cd /mnt/d/xhugo/hue-docs-site
as4k@DESKTOP-PM5KOT8:/mnt/d/xhugo/hue-docs-site$ hugo server -D

增加头部内容脚本

+++
title = "User"
date = 2019-03-13T18:27:26-07:00
+++

################################# mac用 #################################################################

gsed -i '1i +++' tmp.txt
tit=tmp; echo "gsed -i '2i title = \"${tit}\"' tmp.txt"|bash
gsed -i '3i date = 2019-03-13T18:27:26-07:00' tmp.txt
gsed -i '4i +++' tmp.txt


for i in `ls *.md`; do
gsed -i '1i +++' $i
tit=`echo $i | sed 's#\.md$##g'` 
echo "gsed -i '2i title = \"${tit}\"' $i" | bash
gsed -i '3i date = 2019-03-13T18:27:26-07:00' $i
gsed -i '4i +++' $i
done

for i in `ls *.md`; do gsed -i '1i +++' $i; tit=`echo $i | sed 's#\.md$##g'` ; echo "gsed -i '2i title = \"${tit}\"' $i" | bash; gsed -i '3i date = 2019-03-13T18:27:26-07:00' $i; gsed -i '4i +++' $i; done

#################################### 其它用 ######################################################
for i in `ls *.md`; do sed -i '1i +++' $i; tit=`echo $i | sed 's#\.md$##g'` ; echo "sed -i '2i title = \"${tit}\"' $i" | bash; sed -i '3i date = 2019-03-13T18:27:26-07:00' $i; sed -i '4i +++' $i; done

参考资料

https://gohugo.io/hosting-and-deployment/hosting-on-github/

https://blog.coderzh.com/2015/08/29/hugo/

https://gohugo.io/showcase/linode/

http://localhost:1313/hugo/

https://themes.gohugo.io/hugo-book/

https://github.com/matcornic/hugo-theme-learn

https://learn.netlify.com/en/

https://learn.netlify.com/en/cont/pages/

Hugo中文文档 快速开始
https://www.gohugo.org/