1.下载hugo
(1)下载:Releases · gohugoio/hugo · GitHub 例如:window用户就直接下载hugo_0.55.6_Windows-64bit.zip版本
(2)解压到bin目录以后,生成一个exe文件,其实就是hugo命令包,将此包所在目录配置到path环境中。 使用下面的命令如果出现版本号,说明配置成功:
hugo version
2.部署hugo本地站点
生成一个名为myblog的博客站点:
hugo new site myblog
初始化myblog站点:
cd myblog
git init
git clone https://github.com/koirand/pulp.git themes/pulp # 下载主题pulp
cd themes
git init # 将主题所在目录也当作一个git仓库使用,用户以后上传文件public与github仓库之间的管理
cd ../
git submodule add xxx.git themes/pulp # 主题使用了pulp初始化站点,xxx.git就是你的仓库的全部url(如:https://github账号.仓库名.git )
你的配置文件config.toml:
baseurl = "https://xxx.github.io" # xxx.github.io就是你github仓库的名称
title = "QL's blog"
theme = "pulp"
canonifyurls = true
hasCJKLanguage = true
# pygmentsCodefences = true
# pygmentsUseClasses = true
# googleAnalytics = "{your tracking code}"
[taxonomies]
series = "series"
[params]
author = "QLan"
avatar = "avatar.png"
favicon = "favicon.ico"
description = """
真正的能力是在现有的条件下解决问题,没有条件创造条件也要解决问题。
"""
publicationYear = "2019"
# listPageDateFormat = "January, 2006" # See https://gohugo.io/functions/format/
# singlePageDateFormat = "January 2, 2006"
# custom_css = ["/css/custom.css"]
# custom_js = ["/js/custom.js"]
[outputs]
section = ["JSON", "HTML"]
[[menu.main]]
identifier = "blog"
# name = "Blog" #If display text link, cancel comment out
pre = "<i class='fa fa-book-open fa-lg'></i>" #Choose your favorite font from Font Awesome
url = "/blog/"
weight = 10
[[menu.main]]
identifier = "zhihu"
# name = "Zhihu"
pre = "<i class='fa fa-user-circle fa-lg' aria-hidden='true'></i>"
url = "https://www.zhihu.com/people/hong-shao-yu-kuai-12/activities"
weight = 20
[[menu.main]]
identifier = "github"
# name = "GitHub"
pre = "<i class='fab fa-github fa-lg'></i>"
url = "https://github.com/LUK-qianliu"
weight = 30
[[menu.main]]
identifier = "email"
# name = "Email"
pre = "<i class='fa fa-envelope fa-lg'></i>"
url = "mailto:532433365@qq.com"
weight = 40
[[menu.main]]
identifier = "about"
# name = "About"
pre = "<i class='fa fa-heart fa-lg'></i>"
url = "/about"
weight =50
[[menu.main]]
identifier = "csdn"
# name = "SCDN"
pre = "<i class='fa fa-rss' aria-hidden='true'></i>"
url = "https://blog.csdn.net/qq_35688140"
weight =60
3.本地测试
本地启动hugo站点
hugo server -t pulp # 以pulp为主题启动站点
本地测试,直接访问:http://localhost:1313/.
4.github与本地仓库关联
(1)利用现有的markdown文本生成一个public文件,该public文件是一个网页展示文件:
hugo --theme=pulp --baseUrl="https://LUK-qianliu.github.io/" -D
(2)然后将生成的public文件上传到github即可
git add *
git commit -m "Initial commit."
git remote add origin https://github.com/LUK-qianliu/LUK-qianliu.github.io
git push -u origin master