5

hexo转到hugo

 2 years ago
source link: https://www.bboy.app/2022/09/04/hexo%E8%BD%AC%E5%88%B0hugo/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

hexo转到hugo

2022-09-04 21:05:00 linux

20220904-1.webp

随着文章越来越多,hexo明显编译时间变久了,虽然配置了流水线少了很多手动操作的步骤,但是发布一次3分钟的编译时间明显不是我所喜欢的,所以花了半天的时间把博客从hexo切换到了hugo,可能大家不会感到有很明显的变化,因为都是用的是next主题

看了下hexo-next主题

https://github.com/theme-next/hexo-theme-next

最近一次master分支提交是2021年7月

果断更换成

https://github.com/hugo-next/hugo-theme-next

首先下载hugo

wget https://github.com/gohugoio/hugo/releases/download/v0.102.1/hugo_extended_0.102.1_Linux-64bit.tar.gz

tar -zxvf hugo_0.102.0_Linux-64bit.tar.gz

mv hugo /bin/

创建新站点

hugo new site hugo-next-exmaple

cd hugo-next-exmaple

git init

git submodule add https://github.com/hugo-next/hugo-theme-next.git themes/hugo-theme-next

cp -r themes/hugo-theme-next/exampleSite/* .

rm -rf config.toml

修改文章头部

我之前的文章头部是这样的

---
title: 20220829的胡言乱语
tags:
  - 胡言乱语
categories: 胡言乱语
date: 2022-08-29 14:35
---

date这里是没有秒的,如果没有秒日期会有问题,所以使用vscode批量替换

查找: date:(.*) 替换: date: $1:00

阅读更多也要替换

原先是有空格的: <!-- more --> 改为没有空格: <!--more-->

hexo 中我的分类是这样的

categories: 胡言乱语

hugo中要变成数组

categories:
  -  胡言乱语

然后网站的url也要替换

config.yaml中加入

permalinks:
  post: /:year/:month/:day/:title/

ci这里就简单的优化了下Dockerfile,然后整个发布流程从3分多钟缩短到1分钟左右

果然Hugo比hexo快多了

rss支持

原先我的rss url 是url/atom.xml的,这里也需要修改

outputFormats:
  RSS:
    baseName: "atom"

欢迎关注我的博客 www.bboy.app

Have Fun


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK