简介
Hugo 是一个用 Go 编写的静态 HTML 和 CSS 网站生成器。它针对速度、易用性和可配置性进行了优化。Hugo 将一个包含内容和模板的目录渲染成一个完整的 HTML 网站。
项目地址:https://github.com/gohugoio/hugo
官网:https://gohugo.io
原本使用的博客是用 Hexo 作为生成器,主题为 Matery,但仍觉不够简洁
遂转战用 Hugo 作为生成器,主题用的 MemE
搭建
安装 Hugo
参考快速上手文档:https://gohugo.io/getting-started/installing/
Mac 直接使用 Homebrew 安装
|
|
创建项目
|
|
安装主题 MemE
|
|
替换配置文件
|
|
初始化
|
|
本地运行
|
|
默认运行在 http://127.0.0.1:1313
撰写
存放文章的路径在 /content/post
,/content/about
中存放着关于页面的内容
文章元信息示例:
|
|
需要注意的是,默认模版中会有 Draft 的选项,译为草稿,当选项打开(即为 true)时,默认不会渲染,一般建议不要添加该项(
关于
页面死活加载不出来,找半天原因,原来是默认加上了 Draft :)
图片可以放在 static
文件夹中,引用时直接使用 /<pic_name>
就行了
部署
准备仓库
就不在这里赘述了
生成静态文件
|
|
前提是已经在配置文件中配置默认主题及项目地址,否则
|
|
上传部署
不出意外的话,要出意外了,项目根目录会多出 public
文件夹
|
|
如果有自己的域名,到 /static
中添加 CNAME 文件,里面放自己的域名
其他
MemE 主题添加 Giscus 评论系统
参考大佬给出的文件改动参考:https://github.com/reuixiy/hugo-theme-meme/pull/397/files
支持的 Front Matter
Name | Description | Notes |
---|---|---|
title | * | string |
linkTitle | * | string |
subtitle | displayed below the title | string, Markdown supported |
date | * | string |
lastmod | * | string |
publishDate | * | string |
expiryDate | * | string |
<taxonomies> eg: categories, tags, series |
* | array |
description | * | string, Markdown supported |
summary | * | string, Markdown supported |
images | * | array |
slug | * | string |
url | * | string |
draft | * | boolean |
isCJKLanguage | * | boolean |
weight | * | integer |
type | * | string, if equal to "poetry", will use a special layout for it |
layout | * | string |
outputs | * | array |
aliases | * | array |
markup | * | string |
hideInHomepage | hide this post in homepage posts list | boolean, valid for "posts" homepage with enableHideInHomepage enabled |
meta | set false to disable post-meta |
boolean, override enablePostMeta in config.toml |
displayPublishedDate | display published date in post-meta | boolean, override displayPublishedDate in config.toml |
displayModifiedDate | display modified date in post-meta | boolean, override displayModifiedDate in config.toml |
displayExpiryDate | display expiry date in post-meta | boolean, override displayExpiryDate in config.toml |
displayCategory | display category in post-meta | boolean, override displayCategory in config.toml |
displayWordCount | display word count in post-meta | boolean, override displayWordCount in config.toml |
displayReadingTime | display reading time in post-meta | boolean, override displayReadingTime in config.toml |
displayBusuanziPagePV | display page views in post-meta | boolean, override displayBusuanziPagePV in config.toml |
toc | display TOC | boolean, override enableTOC in config.toml |
tocNum | display TOC number | boolean, override displayTOCNum in config.toml |
anchor | enable headings anchor | boolean, override enableHeadingsAnchor in config.toml |
displayCopyright | display post-copyright | boolean, override displayPostCopyright in config.toml |
badge | display updated-badge | boolean, override displayUpdatedBadge in config.toml |
gitinfo | display post-gitinfo | boolean, override displayPostGitInfo in config.toml |
share | display post-share | boolean, override displayPostShare in config.toml |
related | display related-posts | boolean, override displayRelatedPosts in config.toml |
katex | add KaTeX support | boolean, override enableKaTeX in config.toml |
mathjax | add MathJax support | boolean, override enableMathJax in config.toml |
mermaid | add Mermaid support | boolean, override enableMermaid in config.toml |
comments | set false to disable comments in mainSections or set true to enable comments in non-mainSections |
boolean |
smallCaps | small caps? | boolean, override enableSmallCaps in config.toml |
dropCap | drop cap? | boolean, override enableDropCap in config.toml |
dropCapAfterHr | drop cap after every horizontal rule tag? | boolean, override enableDropCapAfterHr in config.toml |
deleteHrBeforeDropCap | delete horizontal rule tag before drop cap? | boolean, override deleteHrBeforeDropCap in config.toml |
indent | indent instead of margin? | boolean, override paragraphStyle in config.toml |
indentFirstParagraph | indent the first paragraph? | boolean, override indentFirstParagraph in config.toml |
align | normal, justify, center | string, if equal to "normal", will override enableJustify in config.toml |
original | original? You can add the following 8 terms if you set false . The author is required, other optional |
boolean, override original in config.toml |
author | author of original post | string |
link | link of original post | string, URL |
copyright | license of the post | string, Markdown supported |
website | author’s website | string |
author’s email | string | |
motto | author’s description | string |
avatar | author’s avatar | string, URL |
author’s twitter id | string | |
disqus_url | * | string, if not set, will use Permalink as default |
disqus_identifier | * | string, if not set, will use RelPermalink as default |
disqus_title | * | string, if not set, will use Title as default |