Hexo使用Matery主题遇到的一些问题

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)


折腾了几个小时发现最终的解决办法很简单,**只需点击报错的链接同意推送即可**。

  • 5
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Hexo Matery是一款基于Hexo的个性化主题,可以用于搭建个人博客网站。要使用Hexo Matery主题,首先需要在根目录的_config.yml文件中找到theme配置项,并将其更改为"matery"。然后执行"hexo clean"命令清理一下,再执行"hexo g"命令重新生成静态页面,最后执行"hexo s"命令运行本地服务器。在浏览器中输入"localhost:4000"访问你的网站,你会发现主题已经成功更改。 如果你想要开启文章字数统计功能,还需要安装hexo-wordcount插件。可以通过执行命令"npm i --save hexo-wordcount"进行安装。如果npm命令加载慢,还可以尝试使用cnpm命令进行安装。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [hexo博客matery主题的个性化配置](https://blog.csdn.net/qq_41376237/article/details/113475727)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *3* [hexomatery主题的个性化定制](https://blog.csdn.net/weixin_46399753/article/details/104768713)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值