Hexo使用Matery主题遇到的一些问题
所用主题为Matery
文章字数统计插件的安装
npm i --save hexo-wordcount
在主题配置界面激活配置。
postInfo:
date: true
update: true
wordCount: false # 设置文章字数统计为 true.
totalCount: false # 设置站点文章总字数统计为 true.
min2read: false # 阅读时长.
readCount: false # 阅读次数.
执行以上代码安装字数统计插件并激活配置
结果执行hexo cl,hexo g ,hexo s均会报错,报错内容如下:
关键点在ERROR Plugin load failed: hexo-wordcount
Error: Cannot find module ‘hexo-util’,
后发现是缺少hexo-util的包,只需执行以下语句即可解决
npm install hexo-util --save
解决Hexo+Matery主题下本地网页和git均不显示图片的问题
如出现上图这样的情况,并且无论使用绝对路径还是相对路径均不显示的问题。
首先确定是否安装了hexo-asset-image的插件,如没有安装,则需要安装
npm install hexo-asset-image --save
安装后仍需要在配置界面_config.yml将下面配置改为true
post_asset_folder: true
配置界面改为true后会,在使用
hexo new "文章名字"
创建新的文章时,会在文章同目录下建立同名文件夹用以存放图片。
如果上面都步骤都做了还是无法在文章中看到图片,可能是因为这个插件已经好久没有更新,太老了。就需要更改hexo-asset-image文件夹中的index.js的代码
路径:Blog\node_modules\hexo-asset-image\index.js
打开index.js文件找到第58行更改代码为:
$(this).attr('src', src);
更改完成后,在blog根目录依次执行hexo cl,hexo g ,hexo s.打开本地网页应该就可以正常显示图片了。
解决hexo d不能推送到github
在此处默认已经配置过git以及ssh,但是不能上传成功出现以下报错
! [remote rejected] HEAD -> main (push declined due to repository rule violations)
error: failed to push some refs to ‘github.com:LKY02/LKY02.github.io.git’
使用以下命令测试本地与仓库的联通性
ssh -T git@github.com
回应:**Hi LKY02! You’ve successfully authenticated, but GitHub does not provide shell access.**说明此时本地与仓库可以正常连接,没有问题。根据在以下的报错信息,发现是由于密码中含有秘密。只需同意将秘密上传至github仓库即可。
全部报错代码如下:
PS C:\Users\Administrator\Desktop\nblog> hexo d
INFO Validating config
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
INFO Copying files from extend dirs...
On branch master
nothing to commit, working tree clean
Enumerating objects: 295, done.
Counting objects: 100% (295/295), done.
Delta compression using up to 16 threads
Compressing objects: 100% (254/254), done.
Writing objects: 100% (295/295), 11.28 MiB | 1.46 MiB/s, done.
Total 295 (delta 39), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (39/39), done.
remote: error: GH013: Repository rule violations found for refs/heads/main.
remote:
remote: - GITHUB PUSH PROTECTION
remote: —————————————————————————————————————————
remote: Resolve the following violations before pushing again
remote:
remote: - Push cannot contain secrets
remote:
remote:
remote: (?) Learn how to resolve a blocked push
remote: https://docs.github.com/code-security/secret-scanning/pushing-a-branch-blocked-by-push-protection
remote:
remote:
remote: —— Tencent Cloud Secret ID ———————————————————————————
remote: locations:
remote: - commit: e10027b37dc7bb989d76aa5a07708301ff6b75d4
remote: path: libs/twikoo/twikoo.all.min.js:2
remote:
remote: (?) To push, remove secret from commit(s) or follow this URL to allow the secret.
remote: https://github.com/LKY02/LKY02.github.io/security/secret-scanning/unblock-secret/2hhBY26sWZNuE15DIfRZz742OpI
remote:
remote:
remote:
To github.com:LKY02/LKY02.github.io.git
! [remote rejected] HEAD -> main (push declined due to repository rule violations)
error: failed to push some refs to 'github.com:LKY02/LKY02.github.io.git'
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (C:\Users\Administrator\Desktop\nblog\node_modules\.store\hexo-util@2.7.0\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:519:28)
at cp.emit (C:\Users\Administrator\Desktop\nblog\node_modules\.store\cross-spawn@7.0.3\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
折腾了几个小时发现最终的解决办法很简单,只需点击报错的链接同意推送即可。
ib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
折腾了几个小时发现最终的解决办法很简单,**只需点击报错的链接同意推送即可**。