使用hugo创建自己的blog
安装
Centos 系统安装方法:
yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/repo/epel-7/daftaupe-hugo-epel-7.repo
yum -y install hugo
hugo version
Mac 系统安装方法: 使用
# 安装
brew install hugo
# 测试
hugo version
如果 安装不成功,可以直接下载二进制文件安装 下载并解压后。
# 改成可运行
chmod +x hugo
# 放到用户目录
mv hugo /usr/local/bin/
# 测试
hugo version
之后的创建站点、使用主题、添加内容、启动等都可以从quick-start查看到。
debian 系统安装方法
apt install -y hugo
创建 blog
- 参考 官方教程初始化一个 blog
# 找一个文件夹
mkdir -p /usr/share/www
cd /usr/share/www && hugo new site myblog
cd myblog
git init
# 配置主题
git submodule add https://gitee.com/smile365/wehuth.git themes/wehuth
# 配置文件
cp themes/wehuth/exampleSite/config.toml .
- 创建文章
# hugo new posts/my-first-post.md
# ~/content/posts/my-first-post.md created
git submodule add https://github.com/smile365/blog.git content/posts
# hugo server
hugo server -D -t wehuth --bind=0.0.0.0 --baseURL=http://127.0.0.1:1313
Hugo 文章列表无法正确显示的解决方法
在其他地方显示正常的md文件,在hugo下显示错误。其原因是hugo使用了Blackfriday作为Markdown解析引擎。
方法一:在列表前方增加一行空行
list
- item1
- item2
方法二:配置Blackfriday对列表前无需空行vim config.toml
[blackfriday]
extensions = ["noEmptyLineBeforeBlock"]
测试
# test whith draft posts
$ hugo server -D -t wehuth --bind=0.0.0.0 --baseURL=http://127.0.0.1:1313
开启百度统计
按照要求把百度统计代码复制到模版的single.html/list.html等地方。
先去注册leancloud
创建应用, 把代码复制到需要的地方
把代码复制到模版的single.html页面
推荐主题:
参考