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 2 3 4 5 npm install -g hexo-cli hexo init <folder> cd <folder> npm install
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 2 3 4 5 # use 'custom.yml' in place of '_config.yml' $ hexo server --config custom.yml # use 'custom.yml' & 'custom2.json', prioritizing 'custom2.json' $ hexo server --config custom.yml,custom2.json
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 2 3 cd hexo-site npm install hexo-theme-next 通过npm安装next
更新next主题(前提是使用npm安装的) 1 2 3 cd hexo-site npm install hexo-theme-next@latest 通过npm更新next(前提是通过npm安装的)
git安装next方法
1 2 cd hexo git clone https://github.com/theme-next/hexo-theme-next themes/next
git升级next方法
重新安装依赖: 字数统计 [Hexo Word Counter]https://github.com/next-theme/hexo-word-counter
site config站点配置文件添加内容
1 2 3 4 5 6 7 8 9 10 symbols_count_time: symbols: true time: true total_symbols: true total_time: true exclude_codeblock: false awl: 4 wpm: 275 suffix: "mins."
next theme config自定义文件添加内容
1 2 3 4 5 6 7 post_meta: item_text: true symbols_count_time: separated_meta: true item_text_total: false
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 2 3 $ cd hexo-site/source/lib/pdf $ git pull
黑暗模式 安装
1 2 npm install hexo-next-darkmode --save
https://github.com/rqh656418510/hexo-next-darkmode
Git部署安装 1 npm install hexo-deployer-git --save
1 2 3 4 5 deploy: type: git repo: <repository url> # https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io branch: [branch] message: [message]
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 2 3 4 5 6 7 8 9 10 deploy: type: sftp host: <host> user: <user> pass: <password> remotePath: [remote path] port: [port] privateKey: [path/to/privateKey] passphrase: [passphrase] agent: [path/to/agent/socket]
上面代码内容的解释
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 2 3 4 5 6 7 8 --- title: Hello World date: 2016-03-30 21:18:02 password: hello ---
可在文章中直接自定义密码相关显示内容,若要不加密,只需将改为password:””
1 2 3 4 5 6 7 8 9 10 11 12 13 14 --- title: Hello World tags: - 作为日记加密 date: 2016-03-30 21:12:21 password: mikemessi abstract: 有东西被加密了, 请输入密码查看. message: 您好, 这里需要密码. wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试. wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容. --- Use a "" to diable tag encryption.For example,password:""
也可以在站点配置文件中配置,优先级:文章信息头 > _config.yml
(站点根目录下的) > 默认配置
1 2 3 4 5 6 7 8 9 10 11 12 # Security encrypt: # hexo-blog-encrypt abstract: 有东西被加密了, 请输入密码查看. message: 您好, 这里需要密码. tags: - {name: tagName, password: 密码A} - {name: tagName, password: 密码B} wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试. wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.
还可以禁止产生log,在站点文章中增加以下内容
1 2 3 # Security encrypt: # hexo-blog-encrypt silent: true
以及修改主题样式(??也许是加密的样式更改,应该不会是直接更改页面主题吧)
具体内容详见: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
https://github.com/hexojs/hexo-generator-feed
1 npm install hexo-generator-feed --save
在个人配置文件中添加以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 feed: enable: true type: atom path: atom.xml limit: 20 hub: content: content_limit: 140 content_limit_delim: ' ' order_by: -date icon: icon.png autodiscovery: true template:
站点地图 Hexo安装sitemap
1 2 npm install hexo-generator-sitemap --save #sitemap.xml适合提交给谷歌搜素引擎 npm install hexo-generator-baidu-sitemap --save #baidusitemap.xml适合提交百度搜索引擎
hexo cl && hexo g
会在/public目录下生成sitemap.xml
和baidusitemap.xml
,这就是你的站点地图。
摘自:https://www.cnblogs.com/brady-wang/p/8493181.html文章中有更多关于网站SEO的具体事项,但不容易操作(多而杂),学习成本较高
npm升级 自身升级 升级依赖等 黑客404页面主题配置 html页面下载
代码折叠显示功能 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
https://hexo-next.readthedocs.io/zh_CN/latest/next/base/%E6%A0%87%E7%AD%BE%E9%A1%B5%E8%AE%BE%E7%BD%AE/
##############################################
更新bug:首页之后的第一页页脚歪,表现在sidebar显示的时候,首页页脚也是歪的
有时莫名其妙又好了