建站指南&&使用指南&&维修指南

tiny_star Lv3

本文记录该免费个人博客搭建指南(空间大了可能就不免费了😭,短时间应该不会),以及使用指南(防止长时间不用忘记如何操作)

首页按更新时间排序

打开hexo源目录下\node_modules\hexo-generator-index\lib\generator.js文件,按注释修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';

const pagination = require('hexo-pagination');

module.exports = function(locals) {
const config = this.config;
const posts = locals.posts.sort('-updated'); // 将括号内修改为'-updated'

posts.data.sort((a, b) => (b.sticky || 0) - (a.sticky || 0));

const paginationDir = config.index_generator.pagination_dir || config.pagination_dir || 'page';
const path = config.index_generator.path || '';

return pagination(path, posts, {
perPage: config.index_generator.per_page,
layout: config.index_generator.layout || ['index', 'archive'],
format: paginationDir + '/%d/',
data: {
__index: true
}
});
};

Hexo 指令

1
2
3
4
5
6
7
8
// 新建一篇文章
hexo new
// 生成静态文件
hexo g
// 部署你的网站
hexo d
// 清除缓存文件 (db.json) 和已生成的静态文件 (public)
hexo clean

文本开始位置Tab不显示问题

在S:\Hexo-Blog\themes\redefine\source\css\style.styl文件末尾加入

1
2
3
4
5
6
7
// 修复Tab显示问题
p {
white-space: pre-wrap !important
tab-size: 4 !important
-moz-tab-size: 4 !important
-o-tab-size: 4 !important
}

报错

hexo g

问题:YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key

通常发生在 Hexo 的 Markdown 文件 Front-matter(文章开头的配置区域)格式不正确时
YAML 解释器尝试解析你的文件头部,但由于格式错误,它把正文内容(如第 10 行的二级标题)也当成了配置信息来解析,从而导致报错
原因:缺少闭合的 Front-matter 标记

解决办法:补充闭合的 Front-matter 标记

hexo 标题特殊符号引发错误(冒号、引号、大括号)

问题:YAMLException: bad indentation of a mapping entry (1:55)

解决方法1:使用单引号把标题引起来

1
title: '【Book】Programming Massively Parallel Processors: A Hands-on Approach, Fourth Edition(Wen-mei W. Hwu, David B. Kirk, Izzat El Hajj)'

解决放法2:使用HTML 字符实体

HTML 字符实体

  • Titre: 建站指南&&使用指南&&维修指南
  • Auteur: tiny_star
  • Créé à : 2025-08-07 11:23:39
  • Mis à jour à : 2026-01-01 11:42:10
  • Lien: https://tiny-star3.github.io/2025/08/07/Sundry/建站指南&&使用指南&&维修指南/
  • Licence: Cette œuvre est sous licence CC BY-NC-SA 4.0.
Commentaires