Hugo快速起步

在完成 Hugo安装 后,可以快速使用Hugo构建一个网站

创建 docs.cloud-atlas.io 网站
hugo new site docs.cloud-atlas.io

此时提示如下:

创建 docs.cloud-atlas.io 网站输出信息
Congratulations! Your new Hugo site was created in /Users/huatai/docs/github/huataihuang/docs.cloud-atlas.io.

Just a few more steps...

1. Change the current directory to /Users/huatai/docs/github/huataihuang/docs.cloud-atlas.io.
2. Create or install a theme:
   - Create a new theme with the command "hugo new theme <THEMENAME>"
   - Or, install a theme from https://themes.gohugo.io/
3. Edit hugo.toml, setting the "theme" property to the theme name.
4. Create new content with the command "hugo new content <SECTIONNAME>/<FILENAME>.<FORMAT>".
5. Start the embedded web server with the command "hugo server --buildDrafts".

See documentation at https://gohugo.io/.

Themes

Hugo Themes 找到心仪的Theme

备注

我这里选择 Hugo Geekdoc 构建一个简单的 docs.cloud-atlas.io 页面来引导阅读我撰写的不同文档手册

另外,对于个人网站导引,可以采用 Hugo Lynx

  • 将下载的 hugo-geekdoc.tar.gz 存放到 themes 目录下创建的 Geekdoc 目录中

安装Geekdoc theme
# 在 themes目录下创建
mkdir themes/Geekdoc
cd themes/Geekdoc
cp ~/Downloads/hugo-geekdoc.tar.gz ./
tar xf hugo-geekdoc.tar.gz
  • docs.cloud-atlas.io 项目根目录下的 hugo.toml 中添加一行 theme 配置,并相应编辑对应配置,类似如下:

hugo.toml
baseURL = 'https://docs.cloud-atlas.io/'
languageCode = 'en-us'
title = 'Cloud Atlas Docs'
theme = 'Geekdoc'

运行

  • 执行以下命令启动hugo的web服务:

启动hugo server
hugo server -D

撰写文档

  • 撰写一个页面内容:

发布一个页面
hugo new content content/posts/my-first-post.md

发布网站

  • 执行以下命令,将在 public/ 目录下生成静态网站,然后通过 rsync 同步到 bcloud-w1-r 服务器的 Nginx 的WEB目录下:

发布网站
hugo && rsync -avz --delete public/ bcloud-w1-r:/var/web/cloud-atlas.io/docs/

目前看到的是一个基础的页面,没有内容:

参考