hugo搭建个人博客

433 阅读1分钟

为什么选择hugo

The world’s fastest framework for building websites

因为他是世界上最快的

如何搭建

跟着hugo官网一步步进行

安装hugo

brew install hugo

hugo version

创建一个新站点

hugo new site yoursitename

cd yoursitename
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke

添加anake主题

echo 'theme = "ananke"' >> config.toml

创建第一篇博客

hugo new posts/第一篇博客.md

本地预览

hugo server -D

此时可以本地预览地址默认为localhost:1313

静态编译

hugo -D 此时会生成public文件夹,里边的就是博客所发布的内容

.gitignore

在yoursitename 目录下创建.gitignore 将public文件忽略

上传github

进入public文件夹

git init 
git add .
git commit -m '上传博客'

在github操作如下:

创建一个repo命名为: yourname.github.io

然后上传至github即可访问!!

大功告成

注:使用hugo搭建博客只是体验一下建站流程,并不建议使用hugo进行自己日常博客撰写