老宋专门写了一本关于这个的书html
参考 这个文档有个坑,里面访问的url改为https的.若是按照文档的http会致使发到github上后样式加载不成功.linux
- 将hugo放在可执行路径 $ hugo version Hugo Static Site Generator v0.36 windows/amd64 BuildDate: 2018-02-05T15:23:01Z - 新建站点 mkdir sites cd sites hugo new site quickstart - 新建文章 hugo new posts/ansible经常使用知识点.md - 下载主题 cd themes git clone https://github.com/halogenica/beautifulhugo.git - 构建 hugo server --theme=beautifulhugo --buildDrafts - 本地run hugo server - 构建public静态文件,准备上传html hugo --theme=beautifulhugo --baseUrl="https://lannyMa.github.io/" - 新建github,上传代码到github 如今github新建仓库: <用户名>.github.io,如个人是lannyMa.github.io - 来到本地,上传代码 cd public echo "# lannyMa.github.io" >> README.md git init git add -A git commit -m "first commit" git remote add origin https://github.com/lannyMa/lannyMa.github.io.git git push -u origin master - 而后访问 https://lannyma.github.io/
hugo构建环境模板参考github
每次写一遍md文档,都须要构建,手动推送,这个是很大疼的,有deploy.sh.
正确姿式是,直接执行sh deploy.sh "comment
一键部署
json
这里我是win7,cmd很差用,我改用第三方cmder,这个执行命令比较像linux.windows
deploy.sh也很简单bash
#/bin/bash echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" msg="rebuilding site `date`" if [ $# -eq 1 ] then msg="$1" fi git add -A git commit -m "$msg" git push origin master # Build the project. hugo # if using a theme, replace by `hugo -t <yourtheme>` hugo-algolia # Go To Public folder cd public # Add algolia search index grep -v '"content":' algolia.json>maotai-blog.json rm -f algolia.json # Add changes to git. git add -A # Commit changes. git commit -m "$msg" # Push source and build repos. git push origin master cd ../
这个玩意能够分析一些pv,uv等
服务器
参考: 免费的域名和证书
freenom.com工具
注: 域名的备案问题,若是在国内,若是域名指向了国内的服务器,则须要备案,若是域名cname到了github,则无须要.post
maotai.ml 这是个人站点,我cname到了 lannyma.github.io了.
todo: