centos部署Hugo博客
1.安装Hugo
下载Hugo安装文件并安装
1
|
wget https://github.com/gohugoio/hugo/releases/download/v0.76.5/hugo_0.76.5_Linux-64bit.tar.gz && tar zxf hugo_0.76.5_Linux-64bit.tar.gz && cp hugo /usr/local/bin
|
2.生成文章
通过命令新建一个名为“mysite”的网站
mysite/content是用来存放文档的地方,可以在这里建立一个新的Markdown文件:
在first.md中写入一些内容,
1
2
3
4
5
6
7
8
9
10
|
---
title: first article
id: 1
categories: ["first category"]
date: 2019-12-17T08:52:32+08:00
tags: ["first"]
draft: false
author: "kingem"
---
内容content
|
使用如下命令进行本地预览:
瞬间编译成功,打开网址 http://localhost:1313/ 即可查看本地生成的静态网站。
使用如下命令生成静态文件夹public:
3.安装主题
选择hugo主题,并将其下载到主题文件夹
1
|
git clone https://github.com/spf13/hyde.git themes/hyde
|
编辑theme.toml
对主题进行自定义配置
4.自定义信息
编辑config.toml
中,修改标题title
、描述description
、版权copyright
.
1
2
3
|
title = "我的网页"
description = "我的网页介绍"
copyright = "版权所有"
|
在layouts/_default/single.html与layouts/index.html同时修改日期显示格式
1
|
class="post-date">{{ .Date.Format "2006-01-02 15:04:05" }} 字数:{{ .WordCount }}</time>
|