Hugo 是一个通用的网站框架。从技术上讲,Hugo 是一个静态站点生成器。与根据每个访问者请求动态构建页面的系统不同,Hugo 在您创建或更新内容时构建页面。由于网站的查看频率远高于编辑频率,因此 Hugo 旨在为您网站的最终用户提供最佳的查看体验,并为网站作者提供理想的写作体验。
安装
1
2
3
4
# windows 下使用 scoop 安装
scoop install hugo
# macOS 下使用 brew 安装
brew install hugo
安装完就来验证一下吧
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 创建site
hugo new site quickstart
# 进入site目录cd quickstart
# 初始化
git init
# 选择一个主题
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
# 配置文件设置主题echotheme=\"ananke\" >> config.toml
# 创建文章并修改内容
hugo new posts/my-first-post.md
# 运行本地服务查看效果
hugo server -D
# This references a standard debian container from the# Docker Hub https://registry.hub.docker.com/_/debian/# Read more about containers on our dev center# http://devcenter.wercker.com/docs/containers/index.htmlbox:debian# You can also use services such as databases. Read more on our dev center:# http://devcenter.wercker.com/docs/services/index.html# services:# - postgres# http://devcenter.wercker.com/docs/services/postgresql.html# - mongo# http://devcenter.wercker.com/docs/services/mongodb.html# This is the build pipeline. Pipelines are the core of wercker# Read more about pipelines on our dev center# http://devcenter.wercker.com/docs/pipelines/index.htmlbuild:# Steps make up the actions in your pipeline# Read more about steps on our dev center:# http://devcenter.wercker.com/docs/steps/index.htmlsteps:- script:name:install gitcode:| apt-get update
apt-get install git -y- script:# 如果使用submodules, 记得添加配置文件.gitmodulesname:initialize and update git submodulescode:| git submodule init
git submodule update --remote --recursive- arjen/hugo-build:theme:LoveItflags:--buildDrafts=true- npm-install- script:name:publish algolia jsoncode:|npm run algoliadeploy:steps:- install-packages:packages:git ssh-client# 官方给的lukevivier/gh-pages@0.2.1会部署到gh-pages分支,17年我用的时候没这毛病,这里改用别的Step# 部署public目录下的静态文件至username.github.io的master分支- sf-zhou/gh-pages@0.2.6:token:$GIT_TOKENdomain:http://blog.orionpax.toprepo:OrionPax19970905/OrionPax19970905.github.iobranch:masterbasedir:public
同款 Blog 搭建保姆级全流程
(可选,已有 GitHub 账号的跳过这一步) 注册并登录 GitHub
点击 clone 通过 Vercel 模版 构建项目,输入项目名称创建项目,填写环境变量并点击 Deploy,耐心等待一段时间,Congratulations! 点击 Go to Dashboard - Visit 你已经看到你的博客网站了。使用 Vercel 创建的项目是已经配置了 CI 的,当你向 GitHub 的仓库提交代码时,Vercel 会自动重新打包并发布项目,因此你做的所有提交都会使网站重新构建。