更新于 

站点配置

站点配置

_config.yml 是 Hexo 的主配置文件,控制站点的基本信息、URL、部署等。

基本信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 站点标题
title: My Blog

# 站点副标题
subtitle: 记录生活与技术

# 站点描述(用于 SEO)
description: 一个关于技术与生活的个人博客

# 站点关键词
keywords:
- 博客
- 技术
- 生活

# 作者名
author: Your Name

# 语言
language: zh-CN

# 时区
timezone: Asia/Shanghai

URL 配置

1
2
3
4
5
6
7
8
9
# 站点地址
url: https://your-domain.com

# 文章永久链接格式
permalink: posts/:abbrlink/

# 去掉尾部 index.html
pretty_urls:
trailing_index: false

常用永久链接格式

格式示例
:year/:month/:day/:title//2024/01/01/hello-world/
posts/:title//posts/hello-world/
posts/:abbrlink//posts/a1b2c3/

目录配置

1
2
3
4
5
source_dir: source      # 源文件目录
public_dir: public # 生成的静态文件目录
tag_dir: tags # 标签页目录
archive_dir: archives # 归档页目录
category_dir: categories # 分类页目录

文章配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 新文章的文件名格式
new_post_name: :title.md

# 默认布局
default_layout: post

# 代码高亮
syntax_highlighter: highlight.js
highlight:
line_number: true
wrap: true

# 文章分页
per_page: 10
index_generator:
path: ''
per_page: 10
order_by: -date

部署配置

GitHub Pages

1
2
3
4
deploy:
type: git
repo: git@github.com:username/username.github.io.git
branch: gh-pages

多仓库部署

1
2
3
4
5
6
7
deploy:
- type: git
repo: git@github.com:username/username.github.io.git
branch: gh-pages
- type: git
repo: git@gitee.com:username/username.git
branch: master

插件配置

1
2
3
4
plugins:
- hexo-generator-search
- hexo-generator-feed
- hexo-related-popular-posts

配置说明

  • _config.yml 是 Hexo 的全局配置
  • _config.stellar.yml 是 Stellar 主题的配置(独立文件)
  • 两者都在博客根目录
  • 修改配置后需要 hexo clean && hexo generate 才能生效

💡 提示:更多配置项请参考 Hexo 官方文档


本站由 Moriefy 使用 Stellar1.22.1 主题创建
使用Hexo Github Vercel 强力驱动
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。

发表了 16 篇文章 · 总计 18.5k 字