安装 hugo#
Macos 安装 hugo
brew install hugo
主题 blowfish#
- 克隆到本地
git init -b main
git submodule add -b main https://github.com/nunocoracao/blowfish.git themes/blowfish
. 进入themes/blowfish目录,找到archetypes和config目录,复制到站点根目录的archetypes和config,提示要替换文件选择「是」
.
├─ archetypes # 复制到这儿
├─ assets
├─ config # 和这儿
├─ content
├─ data
├─ i18n
├─ layouts
├─ public
├─ static
└─ themes
└─ blowfish
├─ .github
...
├─ archetypes # 将这个文件夹
...
├─ config # 和这个文件夹
...
进入你刚刚复制的config/_default文件夹中,将languages.en.toml、menus.en.toml两个文件中间的en改为你的默认语言,例如languages.zh-cn.toml、menus.zh-cn.toml
现在回到你的站点根目录,进入刚刚复制过来的config/_default文件夹中,找到hugo.toml文件,可以在开头看到下面这一段,先添加一句在下面hasCJKLanguage = true,用来后面开启正确的汉字计数。
- 取消第五、六行的注释
- 将your_domain.com替换为你的域名,如果没有域名,可以将其替换为你刚刚创建的git仓库的名字:https://
.github.io,其中 是你的 Github 用户名 - 将en替换为你的默认语言,例如zh-cn表示中文简体
# -- Site Configuration --
# Refer to the theme docs for more details about each of these parameters.
# https://blowfish.page/docs/getting-started/
theme = "blowfish" # UNCOMMENT THIS LINE
baseURL = "https://your_domain.com/"
defaultContentLanguage = "zh-cn"
hasCJKLanguage = true
# Other configuration options...
配置站点#
- 在站点根目录下,找到config/_default文件夹,打开languages.zh-cn.toml文件,以下是我自己的文件,请自行修改:
languageCode = "zh-cn"
languageName = "Simplified Chinese (China)"
weight = 1
title = "庆长安"
[params]
displayName = "简体中文"
isoCode = "cn"
rtl = false
dateFormat = "2006 年 1 月 2 日"
logo = "img/logo.png"
# secondaryLogo = "img/secondary-logo.png"
description = "长安剑客"
copyright = "© 2024 - { year } 庆长安 All Rights Reserved."
[params.author]
name = "庆长安"
email = "qingchangan.cc@outlook.com"
image = "img/blowfish_logo.png"
# imageQuality = 96
headline = "长安剑客"
bio = "长安剑客"
links = [
{ email = "mailto:qingchangan.cc@outlook.com" },
{ github = "https://github.com/qingchangan421" },
]
创建文章#
先修改模版,修改archetypes/default.md,我的内容如下:
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
author: "庆长安"
draft: true
description: ""
tags: [初见]
categories: [博客]
---
浏览器打开http://localhost:1313/就可以访问了。
Hugo 构建命令#
可以解决一些无法渲染的问题
hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify
--cleanDestinationDir构建前先清理目标文件夹,即 public--forceSyncStatic强制同步 static 文件夹--gc构建后执行一些清理任务(删除掉一些没用的缓存文件)--ignoreCache构建时忽略缓存--minify压缩网页代码hugo --help查看所有命令