之前使用grdiea,确实很好,但是灵活性相对差一些,主要比较少的主题可选 因此现在切换到了hugo,整体的构建速度很快,毫秒级的速度,整体设计比较优雅, 对比了一下其他的框架,使用go也不需要那么多的依赖,安装环境方便
自动化部署
加上一些自动化部署,就只需要一些把markdown内容到私有git,程序就自动构建并推送GitHub pages仓库,整体很方便,同时搭建一个预览服务使用systemd托管, 就所见即可得了
脚本
echo "====="
date
git pull
/root/go/bin/hugo --theme=PaperMod --baseUrl='https://firer1946.github.io'
cd public
git add -A
git commit -m 'update'
git push origin master
主题选择
经过一轮对比,选择了PaperMod,外观简洁,且功能也比较齐全,很满意
安装
git clone https://github.com/gohugoio/hugo.git
cd hugo
go install
常用命令
# 创建站点
hugo new site /path/to/site -f yaml
# serve
hugo server --theme=PaperMod --buildDrafts --bind="0.0.0.0" --baseUrl=t.me -p 23333
# 构建
hugo --theme=PaperMod --baseUrl='https://firer1946.'
# 新建文件
hugo new about.md
多语言支持
该主题多语言支持也不错,目前只需要中文和英文就可以了
systemd 预览服务
存为/etc/systemd/system/hugo_preview.service
[Unit]
Description=hugo预览
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/data/devs/hugo_blog
ExecStart=/bin/bash -c '/root/go/bin/hugo server --theme=PaperMod --buildDrafts --bind="0.0.0.0" --baseUrl=a.cc -p 23333 &> /var/log/hugo_preview.log'
Restart=always
[Install]
WantedBy=multi-user.target
配置文件
config.yaml
#baseURL: "http://t.me/"
title: Hadoken
paginate: 5
theme: PaperMod
TimeZone: Asia/Shanghai
enableRobotsTXT: true
buildDrafts: false
buildFuture: false
buildExpired: false
googleAnalytics: G-N747Q6G6NL
permalinks:
posts: /archives/:slug/
minify:
disableXML: true
minifyOutput: true
#outputs:
# home:
# - HTML
# - RSS
# - JSON # is necessary
params:
env: production # to enable google analytics, opengraph, twitter-cards and schema.
title: Hadoken
description: "Hadoken is a personal Blog"
keywords: [Blog, Portfolio, PaperMod]
author: Me
# author: ["Me", "You"] # multiple authors
images: ["<link or path of image for opengraph, twitter-cards>"]
DateFormat: "January 2, 2006"
defaultTheme: auto # dark, light
disableThemeToggle: false
ShowReadingTime: true
ShowShareButtons: true
ShowPostNavLinks: true
ShowBreadCrumbs: true
ShowCodeCopyButtons: false
disableSpecial1stPost: false
disableScrollToTop: false
comments: false
hidemeta: false
hideSummary: false
showtoc: true
tocopen: true
assets:
# disableHLJS: true # to disable highlight.js
# disableFingerprinting: true
favicon: "/images/logo/logo.png"
favicon16x16: "/images/logo/logo.png"
favicon32x32: "/images/logo/logo.png"
apple_touch_icon: "/images/logo/logo.png"
safari_pinned_tab: "/images/logo/logo.png"
label:
text: "Hadoken"
icon: /images/logo/logo.png
iconHeight: 35
# profile-mode
profileMode:
enabled: false # needs to be explicitly set
title: ExampleSite
subtitle: "This is subtitle"
imageUrl: "/images/logo/logo.png"
imageWidth: 120
imageHeight: 120
imageTitle: my image
buttons:
- name: Posts
url: posts
# - name: Tags
# url: tags
- name: Archives
url: archives
taxonomies:
tag: "tags"
category: "categories"
socialIcons:
- name: twitter
url: "https://twitter.com/hl3devil"
- name: stackoverflow
url: "https://stackoverflow.com"
- name: github
url: "https://github.com/firer1946"
analytics:
google:
SiteVerificationTag: "G-N747Q6G6NL"
cover:
image: '/images/logo/2520115.png'
relative: false
linkFullImages: true
# hidden: true # hide everywhere but not in structured data
# hiddenInList: true # hide on list pages and home
# hiddenInSingle: true # hide on single page
# editPost:
# URL: "https://github.com/firer1946/firer1946.github.io"
# Text: "Suggest Changes" # edit text
# appendFilePath: true # to append file path to Edit link
# for search
# https://fusejs.io/api/options.html
fuseOpts:
isCaseSensitive: false
shouldSort: true
location: 0
distance: 1000
threshold: 0.4
minMatchCharLength: 0
keys: ["title", "permalink", "summary", "content"]
# Read: https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs#using-hugos-syntax-highlighter-chroma
pygmentsUseClasses: true
markup:
highlight:
# anchorLineNos: true
codeFences: true
guessSyntax: true
lineNos: true
style: solarized
noClasses: false
goldmark:
renderer:
hardWraps: true
# 多语言支持
defaultContentLanguage: zh
languages:
en:
contentDir: content/english
languageName: English
menu:
main:
- identifier: archives
name: archives
url: /archives/
weight: 5
- identifier: categories
name: categories
url: /categories/
weight: 10
# - identifier: tags
# name: tags
# url: /tags/
# weight: 20
- identifier: about
name: about
url: /about/
weight: 50
# - identifier: search
# name: search
# url: /search/
# weight: 50
# - identifier: firer1946
# name: firer1946
# url: https://firer1946.github.io
# weight: 30
params:
homeInfoParams:
Title: "Hadoken \U0001F44B"
Content: To give anything less than your best is to sacrifice the gift.
weight: 10
zh:
contentDir: content/chinese
languageName: Chinese
menu:
main:
- identifier: archives
name: 归档
url: /archives/
weight: 5
- identifier: categories
name: 分类
url: /categories/
weight: 10
# - identifier: tags
# name: 标签
# url: /tags/
# weight: 20
- identifier: about
name: 关于
url: /about/
weight: 50
# - identifier: search
# name: 搜索
# url: /search/
# weight: 50
# - identifier: firer1946
# name: firer1946
# url: https://firer1946.github.io
# weight: 30
weight: 10
# home-info mode
homeInfoParams:
Title: "Hi there \U0001F44B"
Content: 对于任何事都不尽力去做就是在浪费才能。