今天正式把之前的博客文章迁移至hugo了,终于不用再忍受hexo缓慢的生成速度了,以下记录一下迁移过程
一、hugo安装
brew install hugo
二、创建网站
hugo new site iblog
三、安装主题
git clone https://github.com/adityatelange/hugo-PaperMod themes/PaperMod --depth=1
cd themes/PaperMod
git pull
四、配置config.yml(不使用config.toml)
baseURL: "https://iblog.zone"
title: ylw's blog
paginate: 10
theme: PaperMod
defaultContentLanguage: zh
permalinks:
posts: /archives/:slug/
enableInlineShortcodes: true
enableRobotsTXT: true
buildDrafts: false
buildFuture: false
buildExpired: false
enableEmoji: true
# googleAnalytics: UA-123-45
minify:
disableXML: true
minifyOutput: false
params:
env: production # to enable google analytics, opengraph, twitter-cards and schema.
#title: iblog.zone
description: "本站主要用来收集整理资料、记录笔记,方便自己查询使用"
author:
# author: ["Me", "You"] # multiple authors
#images: ["<link or path of image for opengraph, twitter-cards>"]
DateFormat: "2006-01-02"
defaultTheme: auto # dark, light
disableThemeToggle: false
ShowReadingTime: true
ShowShareButtons: false
disableSpecial1stPost: true
displayFullLangName: true
ShowPostNavLinks: true
ShowBreadCrumbs: true
ShowCodeCopyButtons: true
ShowToc: true
comments: true
mainSections:
- posts
assets:
# disableHLJS: true # to disable highlight.js
# disableFingerprinting: true
favicon: "/images/favicon.ico"
favicon16x16: "<link / abs url>"
favicon32x32: "<link / abs url>"
apple_touch_icon: "<link / abs url>"
safari_pinned_tab: "<link / abs url>"
#label:
# text: "iblog.zone"
# icon:
# iconHeight: 35
# profile-mode
#profileMode:
# enabled: false # needs to be explicitly set
# title: ExampleSite
# subtitle: "This is subtitle"
# imageUrl: "<img location>"
# imageWidth: 120
# imageHeight: 120
# imageTitle: my image
# buttons:
# - name: Posts
# url: posts
# - name: Tags
# url: tags
# home-info mode
#homeInfoParams:
# Title: "Hi there \U0001F44B"
# Content: Welcome to my blog
cover:
hidden: true # hide everywhere but not in structured data
hiddenInList: true # hide on list pages and home
hiddenInSingle: true # hide on single page
# for search
fuseOpts:
isCaseSensitive: false
shouldSort: true
location: 0
distance: 1000
threshold: 0.4
minMatchCharLength: 0
keys: ["title", "permalink", "summary", "content"]
menu:
main:
- identifier: home
name: Home
url: /
weight: 5
- identifier: categories
name: Categories
url: /categories/
weight: 15
- identifier: archives
name: Archives
url: /archives/
weight: 10
- identifier: tags
name: Tags
url: /tags/
weight: 20
- identifier: search
name: Search
url: /search/
weight: 30
# for search
outputs:
home:
- HTML
- RSS
- JSON # is necessary
taxonomies:
category: categories
tag: tags
series: series
markup:
goldmark:
renderer:
unsafe: true
五、迁移hexo博客内容
主要修改categories和tags的格式和图片映射路径
由{% asset_img xxxx.png%} 到 ![](/images/文章同名目录/xxx.png)
六、生成预览
hugo server
七、部署
# 生成public静态文件
hugo
# 将hexo的.git目录拷贝到public目录
cp -r hexo/.git hugo/public/
# 提交文章 验证
git add .
git commit -m "xx"
git push