5 分钟使用 hugo 搭建一个自己的博客
苏生不惑 · · 1809 次点击 · · 开始浏览Hugo是由Go语言实现的静态网站生成器。相比hexo更简单、易用、高效、易扩展、快速部署。
安装Hugo
下载二进制
进入github下载地址,选择对应系统的二进制文件,比如我的电脑windows 64位就下载 hugo_0.55.5_Windows-64bit.zip
image.png
解压出来就是一个EXE文件,加入到环境变量即可
源码安装
先安装go,git,设置GOPATH
命令行执行 go get -u -v github.com/spf13/hugo,成功后会生成二进制文件
生成站点
打开命令行,我使用的是cmder,当然自带的cmd也行。
mkdir blog
cd blog
hugo new site .
目录结构为
image.png
编写正文
使用md语法编辑文件
hugo new hello.md
vi hello.md
下载主题
cd themes
git clone https://github.com/spf13/hyde.git
运行Hugo
hugo server --theme=hyde --buildDrafts
Building sites ...
| EN
+------------------+----+
Pages | 11
Paginator pages | 0
Non-page files | 0
Static files | 6
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 335 ms
Watching for changes in d:\blog\{content,data,layouts,static,themes}
Watching for config changes in d:\blog\config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
浏览器里打开: http://localhost:1313
image.png
部署到github
在github建立一个repo,比如username.github.io,注意username为自己的用户名,不能为其他的。hugo --theme=hyde --baseUrl="http://xxx.github.io/"
这样静态页面都会生成到 public 目录,将pubilc目录里所有文件 push 到刚创建的Repo的 master 分支就可以了。
cd public
git init
git remote add origin https://github.com/xxx/xxx.github.io.git
git add .
git commit -m "hugo"
git push -u origin master
打开浏览器访问:http://xxx.github.io/
好了,你的博客搭建成功了,开始你的博客之旅吧。
公众号:苏生不惑
扫描二维码关注
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
Hugo是由Go语言实现的静态网站生成器。相比hexo更简单、易用、高效、易扩展、快速部署。
安装Hugo
下载二进制
进入github下载地址,选择对应系统的二进制文件,比如我的电脑windows 64位就下载 hugo_0.55.5_Windows-64bit.zip
image.png
解压出来就是一个EXE文件,加入到环境变量即可
源码安装
先安装go,git,设置GOPATH
命令行执行 go get -u -v github.com/spf13/hugo,成功后会生成二进制文件
生成站点
打开命令行,我使用的是cmder,当然自带的cmd也行。
mkdir blog
cd blog
hugo new site .
目录结构为
image.png
编写正文
使用md语法编辑文件
hugo new hello.md
vi hello.md
下载主题
cd themes
git clone https://github.com/spf13/hyde.git
运行Hugo
hugo server --theme=hyde --buildDrafts
Building sites ...
| EN
+------------------+----+
Pages | 11
Paginator pages | 0
Non-page files | 0
Static files | 6
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 335 ms
Watching for changes in d:\blog\{content,data,layouts,static,themes}
Watching for config changes in d:\blog\config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
浏览器里打开: http://localhost:1313
image.png
部署到github
在github建立一个repo,比如username.github.io,注意username为自己的用户名,不能为其他的。hugo --theme=hyde --baseUrl="http://xxx.github.io/"
这样静态页面都会生成到 public 目录,将pubilc目录里所有文件 push 到刚创建的Repo的 master 分支就可以了。
cd public
git init
git remote add origin https://github.com/xxx/xxx.github.io.git
git add .
git commit -m "hugo"
git push -u origin master
打开浏览器访问:http://xxx.github.io/
好了,你的博客搭建成功了,开始你的博客之旅吧。
公众号:苏生不惑
扫描二维码关注