Hugo博客搭建教程
Hugo介绍
一种基于 Go 语言的博客框架。
Hugo安装(Mac)
brew install hugo创建博客
下面以我的github用户名manuan为例
hugo new site mannuan.github.io安装主题
themes.gohuo.io上面有很多主题可供选择,比如选择m10c
下载m10c
$ cd myblog
$ git clone https://github.com/vaga/hugo-theme-m10c.git themes/m10c修改配置文件 config.toml
添加一行:
theme = "m10c"本地预览
hugo server -D创建第一篇博客
hugo new post/第一篇博客.md创建的博客在 contents/post/下面
使用vscode编辑markdown文件
快捷键 Ctrl+Shift+P,输入 Markwon: Open Preview to the Side,打开预览模式
发布博客到github
在github创建一个名为
mannuan.github.io的仓库。把当前的博客打包到
public目录下面
hugo --baseUrl="https://mannuan.github.io/" -D- 把
public里面的内容同步到github
cd public
git init
git add .
git commit -m 'hugo博客第一次提交'
git remote add origin https://github.com/mannuan/mannuan.github.io.git
git push -u origin master- 打开浏览器输入
https://mannuan.github.io,查看博客。
博客后期维护
- 创建文章:
hugo new post/文章.md- 进行打包:
hugo --baseUrl="https://mannuan.github.io/" -D- 发布博客:
cd public
git add .
git commit -m '第二次提交'
git push -u origin master