Hexo Theme Cxo 项目教程
1. 项目的目录结构及介绍
Hexo Theme Cxo 的目录结构如下:
hexo-theme-Cxo/
├── _config.yml
├── languages/
├── layout/
│ ├── _partial/
│ ├── _widget/
│ ├── index.pug
│ ├── archive.pug
│ ├── post.pug
│ └── page.pug
├── scripts/
├── source/
│ ├── css/
│ ├── fonts/
│ ├── images/
│ └── js/
└── package.json
目录结构介绍:
_config.yml
: 主题的主要配置文件。languages/
: 存放多语言支持的文件。layout/
: 存放模板文件,使用 Pug 编写。_partial/
: 存放部分模板文件,如头部、尾部等。_widget/
: 存放小部件模板文件。index.pug
: 首页模板。archive.pug
: 归档页面模板。post.pug
: 文章页面模板。page.pug
: 页面模板。
scripts/
: 存放脚本文件,用于扩展主题功能。source/
: 存放静态资源文件。css/
: 存放样式文件,使用 Sass 编写。fonts/
: 存放字体文件。images/
: 存放图片文件。js/
: 存放 JavaScript 文件。
package.json
: 项目的依赖管理文件。
2. 项目的启动文件介绍
Hexo Theme Cxo 的启动文件主要是 _config.yml
和 package.json
。
_config.yml
这是主题的主要配置文件,包含了主题的所有配置选项,如站点标题、描述、作者信息、导航菜单、侧边栏设置等。
package.json
这是 Node.js 项目的依赖管理文件,包含了项目所需的依赖包和一些脚本命令。
3. 项目的配置文件介绍
_config.yml
_config.yml
文件包含了主题的所有配置选项,以下是一些常见的配置项:
# Site
title: 站点标题
subtitle: 站点副标题
description: 站点描述
author: 作者名
language: 语言
timezone: 时区
# URL
url: 站点URL
root: 站点根路径
# Writing
new_post_name: :title.md # 新文章的文件名格式
default_layout: post
titlecase: false # 是否将标题转换为标题大小写
external_link:
enable: true # 在新标签中打开外部链接
field: site # 对整个站点生效或仅对文章生效
exclude: ''
# Category & Tag
default_category: uncategorized
category_map:
tag_map:
# Date / Time format
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# Pagination
per_page: 10 # 每页显示的文章数
pagination_dir: page
# Extensions
theme: hexo-theme-Cxo
# Deployment
deploy:
type: ''
package.json
package.json
文件包含了项目的依赖包和一些脚本命令,以下是一些常见的配置项:
{
"name": "hexo-theme-Cxo",
"version": "1.0.0",
"description": "A cool, simple & beautiful theme for Hexo",
"main": "index.js",
"scripts": {
"start": "hexo server",
"build": "hexo generate",
"clean": "hexo clean"
},
"keywords": [
"hexo",
"theme",
"Cxo"
],
"author": "longlongyu",
"license": "MIT",
"dependencies": {
"hexo": "^5.0.0",
"hexo-renderer-pug": "^2.0.0",
"hexo-renderer-sass": "^0.4.0"
}
}