admin

hexo版本升级

admin 分享 2023-08-18 142浏览 0

Hexo 升级比较简单,老方法 npm-checknpm-upgradenpm-update 一键三连。按以下顺序逐步执行完成后,Hexo 版本及系统插件均会升级到最新

 //以下指令均在Hexo目录下操作,先定位到Hexo目录
//查看当前版本,判断是否需要升级
> hexo version

//全局升级hexo-cli
> npm i hexo-cli -g

//再次查看版本,看hexo-cli是否升级成功
> hexo version

//安装npm-check,若已安装可以跳过
> npm install -g npm-check

//检查系统插件是否需要升级
> npm-check

//安装npm-upgrade,若已安装可以跳过
> npm install -g npm-upgrade

//更新package.json
> npm-upgrade

//更新全局插件
> npm update -g

//更新系统插件
> npm update --save

//再次查看版本,判断是否升级成功
> hexo version

也可以用可以用 ncu -u 一把梭

$ npm install npm-check-updates -g
$ ncu
Checking /Users/tommy/blog/package.json
[====================] 16/16 100%

 hexo                    ^4.2.0  →  ^5.0.0
 hexo-generator-sitemap  ^2.0.0  →  ^2.1.0

Run ncu -u to upgrade package.json
$ ncu -u
Upgrading /Users/tommy/blog/package.json
[====================] 16/16 100%

 hexo                    ^4.2.0  →  ^5.0.0
 hexo-generator-sitemap  ^2.0.0  →  ^2.1.0

Run npm install to install new versions.

简单如此,就把 package.json 文件给更新了,果然是一把梭啊,爽~~~

对于强迫症的我,习惯性删除重来是必须的

$ rm -fr node_modules/
$ npm install --save

以我多年来瞎折腾的经验看,肯定还有坑。

运行 hexo server 验证一下我的想法,果不其然:

嗯……「deprecated」啊……查一下官方的 Release Note

果然有个叫「Breaking change」的东东,里面就有说到配置文件的变化。

对比以后,发现主要有如下变化,大家根据自己的需要调整修改就好了:

    pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''

prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:


转载请注明:邓先生工作室 » 分享 » hexo版本升级

版权声明:
    “邓先生工作室”文章为自撰和网摘为一体,网摘文章及图片版权归原作者所有,转载本文请注明出处,请勿用于商务用途。如有侵犯您的权益,请及时联系toneydeng@qq.com予以删除!
发表评论