hugo搭建个人博客

hugo搭建个人博客

1. hugo的安装

windows下hugo的安装

在hugo的官网下载 hugo 的二进制程序 hugo

或者 scoop install hugo

Linux下hugo的安装

sudo apt-get install hugo

验证hugo是否安装成功

在命令行下执行hugo命令,如果得到类似下面结果,则说明你已经成功安装了Hugo

$ hugo version
Hugo Static Site Generator v0.55.6-A5D4C82D windows/amd64 BuildDate: 2019-05-18T07:57:00Z

2. hugo博客的搭建

1)生成站点

hugo new site mysite

上面将在mysite的文件夹内创建一个mysite的静态站点

ff

2)添加一个主题

blog 主题可以自hugo的主题网站上下载hugo theme clone主题到mysite/themes目录下:

1.cd mysite/
2.git clone <https://github.com/vaga/hugo-theme-m10c.git> themes/xxx

3)在blog里面添加内容

hugo new post/myfirst.md

在myfirst.md文档中增加需要加入到blog的内容

4)启动hugo服务器

hugo server -t 主题 -D

5)定制blog 主题

编辑**config.toml**文件,内容如下:

baseURL = <https://example.org/>
languageCode ="en-us"
title="My New Hugo Site"
theme="ananke"

6) 本地调式

hugo server --theme =m10c --buildDrafts

打开http://localhost:1313进行实时调试

3. 将网站部署到github上

1)生成部署页面

hugo --theme=<YOURTHEME> --baseUrl=<YOUR GITHUB REPOSITORY ADDEERES>

则会在当前目录下生成一个public目录,public里面就是要部署到GitHub上的网站页面文件

2)将网站文件部署到你的GitHub上

cd public/
git init
git remote add origin <YOUR GITHUB REPOSITORY ADDEERES>
git add .
git commit -m "your message"
git push -u origin master

3)访问部署好的网站

浏览器输入 https://echoouyang.github.io/