【笔记】部署Hugo博客

前言

部署Hugo博客

准备工作

  • Git

下载脚手架

Go

1
go install github.com/gohugoio/hugo@latest

MacOS

1
brew install hugo

初始化

blog:站点目录名

1
2
3
hugo new site blog
cd blog
git init

配置主题

  • 本文以ananke主题为例
1
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke

配置文件中指定主题

1
echo "theme = 'ananke'" >> hugo.toml

创建文章

file.md:文章文件

1
hugo new posts/file.md
  • 会在content下创建posts目录,并在posts目录下创建.md文件

启动服务

--theme=<theme>-t <theme>:指定主题
--config=<config_file>:指定配置文件

1
hugo server

生成静态文件

1
hugo
  • 生成完成后会生成public目录存放静态文件

完成

参考文献

Hugo官方文档
哔哩哔哩——CodeSheep
gohugoio/hugo