站点配置
站点配置
_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: 记录生活与技术
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/
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 官方文档。