NexT主题配置8.6.1
NexT升级
npm更换镜像源
因为国外源太慢了,所以更换国内源,下面这是淘宝源。
临时用
1 | npm --registry https://registry.npm.taobao.org install express |
持久使用
1 | npm config set registry https://registry.npm.taobao.org |
- 配置后可通过下面方式来验证是否成功
npm config get registry
- 或
npm info express
hexo安装
1 | npm install -g hexo-cli |
NEXT新版本自定义配置文件建议方案
A custom config file path can be specified by adding the --config
flag to your hexo
commands with a path to an alternate YAML or JSON config file, or a comma-separated list (no spaces) of multiple YAML or JSON files.
1 | # use 'custom.yml' in place of '_config.yml' |
We strongly recommend you to store your theme configuration in one place. But in case you have to store your theme configuration separately, you need to know the priority of those configurations: The theme_config
inside site’s primary configuration file has the highest priority during merging, then the dedicated theme configuration file.
The _config.yml
file under the theme directory has the lowest priority.
[next主题官方教程]https://theme-next.js.org/docs/getting-started/
[新版本next自定义样式的建议]https://theme-next.js.org/docs/getting-started/configuration.html
安装next主题(npm安装方法)
1 | cd hexo-site |
更新next主题(前提是使用npm安装的)
1 | cd hexo-site |
git安装next方法
1 | cd hexo |
git升级next方法
1 | cd themes/next |
重新安装依赖:
字数统计
[Hexo Word Counter]https://github.com/next-theme/hexo-word-counter
site config站点配置文件添加内容
1 | symbols_count_time: |
next theme config自定义文件添加内容
1 | post_meta: |
hexo-related-popular-posts近期文章显示
https://github.com/tea3/hexo-related-popular-posts
theme-next-pdf预览器
使用方法,在插入PDF的地方加上
1 | {% pdf /path/to/your/file.pdf %} |
pdf preview 升级方法
https://github.com/next-theme/theme-next-pdf
1 | $ cd hexo-site/source/lib/pdf |
黑暗模式
安装
1 | npm install hexo-next-darkmode --save |
https://github.com/rqh656418510/hexo-next-darkmode
Git部署安装
1 | npm install hexo-deployer-git --save |
1 | deploy: |
Option | Description | Default |
---|---|---|
repo |
URL of the target repository | |
branch |
Branch name. | gh-pages (GitHub) coding-pages (Coding.net) master (others) |
message |
Customize commit message. | Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }} |
token |
Optional token value to authenticate with the repo. Prefix with $ to read token from environment |
sftp 依赖安装
安装
1 | npm install hexo-deployer-sftp --save |
在站点配置文件中添加该内容
1 | deploy: |
上面代码内容的解释
Option | Description | Default |
---|---|---|
host |
Address of remote host | |
user |
Username | |
pass |
Password | |
remotePath |
Root directory of remote host | / |
port |
Port | 22 |
privateKey |
Path to a ssh private key | |
passphrase |
Optional passphrase for the private key | |
agent |
Path to the ssh-agent socket | $SSH_AUTH_SOCK |
加密博文
安装
1 | npm install --save hexo-blog-encrypt |
添加标签password:密码
1 |
|
可在文章中直接自定义密码相关显示内容,若要不加密,只需将改为password:””
1 |
|
也可以在站点配置文件中配置,优先级:文章信息头 > _config.yml
(站点根目录下的) > 默认配置
1 |
|
还可以禁止产生log,在站点文章中增加以下内容
1 | # Security |
以及修改主题样式(??也许是加密的样式更改,应该不会是直接更改页面主题吧)
具体内容详见:https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/ReadMe.zh.md
hexo-leancloud-counter-security阅读次数
简书,新版修复安全性的leancloud配置方法
https://www.jianshu.com/p/e0a719bac963
1 | npm install hexo-leancloud-counter-security |
https://github.com/theme-next/hexo-leancloud-counter-security
hexo-symbols-count-time
1 | npm install hexo-symbols-count-time |
RSS订阅
https://github.com/hexojs/hexo-generator-feed
1 | npm install hexo-generator-feed --save |
在个人配置文件中添加以下内容:
1 | feed: |
站点地图
Hexo安装sitemap
1 | npm install hexo-generator-sitemap --save #sitemap.xml适合提交给谷歌搜素引擎 |
hexo cl && hexo g
会在/public目录下生成sitemap.xml
和baidusitemap.xml
,这就是你的站点地图。
摘自:https://www.cnblogs.com/brady-wang/p/8493181.html文章中有更多关于网站SEO的具体事项,但不容易操作(多而杂),学习成本较高
npm升级
自身升级
升级依赖等
黑客404页面主题配置
代码折叠显示功能
hexo博客代码折叠功能https://www.toimc.com/hexo-usage-2/作者:Brian
fancybox启用无效,也许需要放上图片才能启用fancybox,进而启动jQuery
折叠逻辑
添加code-unfold.js
由于是在next
主题中添加js逻辑,所以我们把code-unfold.js
放置在了themes/next/source/js/code-unfold.js
:
引用code-unfold.js
(全局引用jQuery)
修改文件themes/next/layout/_scripts/index.njk
添加样式
创建highlight.styl
可以添加theme/next/source/css/_common/components/highlight.styl
文件:
引用样式
找到文件themes/next/source/css/_common/components/index.styl
:
hexo的内置标签特性
Tabs tag
##############################################
更新bug:首页之后的第一页页脚歪,表现在sidebar显示的时候,首页页脚也是歪的
有时莫名其妙又好了