node环境
略
初始化
1 | npm install hexo-cli -g |
安装主题
1 | git clone https://github.com/iissnan/hexo-theme-next.git themes/next |
创建页面
1 | hexo new page "tags" |
安装插件
1 | npm install --save hexo-server |
常用命令
1 | # 清空缓存 |
优化
首页博客间距调整
1
2
3 > hexo-theme-next\source\css\_schemes\Mist\_posts-expanded.styl
> .post { margin-top: 60px; }
>
自定义内容区域的宽度
1
2
3
4
5
6 > hexo-theme-next\source\css\_variables\custom.styl
> $content-desktop = 700px
> $content-desktop-large = 900px
> # 此方法不适用于 Pisces Scheme
> # 移动设备下,宽度自适应
>
替换文章标签图标
- themes/hexo-theme-next-6.7.0/layout/_macro/post.swig
1 | 将 |
自定义样式优化
- themes\hexo-theme-next-6.7.0\source\css_custom\custom.styl 追加
1 | // 主页文章添加阴影效果 |
公益404页面优化404效果
在source目录下创建404.html
1
2
3
4
5
6
7
8
9
10
11
12
13<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8;"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="robots" content="all" />
<meta name="robots" content="index,follow"/>
<link rel="stylesheet" type="text/css" href="https://qzone.qq.com/gy/404/style/404style.css">
</head>
<body>
<script type="text/javascript" src="//qzonestyle.gtimg.cn/qzone/hybrid/app/404/search_children.js" charset="utf-8" homePageUrl="https://www.lengyuewusheng.com" homePageName="回到 www.lengyuewusheng.com"></script>
</body>
</html>- 测试只有在发布到github pages上才生效,本地测试无法直接跳转。
文章结尾增加版权声明
- themes/hexo-theme-next-6.7.0/layout/_macro/ 目录下创建 my-copyright.swig
1 | {% if page.copyright %} |
- themes/hexo-theme-next-6.7.0/source/css/_common/components/post/ 目录下创建 my-post-copyright.styl
1 | .my_post_copyright { |
- 修改 themes/hexo-theme-next-6.7.0/layout/_macro/post.swig
1 | {% if theme.wechat_subscriber.enabled and not is_index %} |
- themes/hexo-theme-next-6.7.0/source/css/_common/components/post/post.styl追加一行
1 | @import "my-post-copyright" |
- themes/hexo-theme-next-6.7.0/layout/_macro/ 目录下新建 passage-end-tag.swig
1 | <div> |
- themes/hexo-theme-next-6.7.0/_config.yml中追加
1 | passage_end_tag: |
- 博客文章头中声明copyright
1 | --- |
常见问题
生成发布时报错,几乎没有有效信息。。。
- 报错内容:
1 | H:\hexo-Blog>hexo g -d |
- 处理方案:
此种情况大概率是由于你的博客的Markdown文件中存在非表格格式的竖线或其它Markdown难以解析的符号导致,如果存在竖线,将竖线用
|
替换,如果存在其它特殊符号将符号删除即可。
hexo generate 执行报错
- 报错内容:
1 | H:\hexo-Blog>hexo g |
- 处理方案:
1 | npm uninstall hexo-uglify uglify uglify-js |
- 报错内容:
1 | ERROR path.substring is not a function |
- 处理方案:
1 | 该问题是在升级Next v5.1.4时出现,首先将Next回滚,然后将本地的node_modules文件夹删除,同时删除package-lock.json,重新执行`npm install`生成node_modules目录后恢复。 |
hexo deploy 执行报错
- 报错内容:
1 | fatal: HttpRequestException encountered. |
- 处理方案:
1 | 这种问题可能是因为本地git环境被破坏导致,重装或升级一下本地git即可解决问题。 |