博客多样性,一款多主题自由切换的Hexo主题
在你的 Hexo 项目根目录,执行以下命令,并将 _config.yml 中的 theme 修改为 diversity。
git clone --depth 1 https://github.com/huazie/hexo-theme-diversity themes/diversity
_config.yml
- theme: other-theme
+ theme: diversity
接入其他主题,有如下两种方式【查看 _config.diversity.yml 中 themes 属性配置】:
themes 目录下,并各自命名,如下所示【其中 diversity 是上述所下载的】:├─themes │ ├─diversity │ ├─light │ ├─phase
landscape 主题,如下:"dependencies": {
"hexo-theme-landscape": "^1.0.0"
}
执行以下命令,用以更新 Diversity。
cd themes/diversity git pull
themes/diversity 目录下的 _config.yml 包含如下配置:
title: Diversity
description: 博客多样性,一款多主题自由切换的Hexo主题
image: /images/diversity.png
favicon: /images/diversity.ico
back_image: /images/back.jpg
darkmode: 0
path:
landscape: /images/landscape.jpg
phase: /images/phase.png
light: /images/light.jpg
source:
landscape: https://github.com/hexojs/hexo-theme-landscape
phase: https://github.com/hexojs/hexo-theme-phase
light: https://github.com/hexojs/hexo-theme-light
page:
header_nav_position:
blog_scroll_height: 200
back2top:
enable: true
enable_scroll_percent: false
scroll_percent: 5
position: right
color: "#fc6423"
exclude: [next]
font:
western:
family:
chinese:
family:
nav:
family:
size:
page:
family:
comments:
style: tabs
active:
storage: true
lazyload: false
nav:
#utterances:
# text: Utterances
# order: 0
#gitalk:
# order: 1
utterances:
enable: false
loading: true
repo: user-name/repo-name
issue_term: pathname
theme: github-light
dark: github-dark
gitalk:
enable: false
github_id:
repo:
client_id:
client_secret:
admin_user:
distraction_free_mode: true
proxy: https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token
issue_term: pathname
language:
giscus:
enable: false
loading: true
repo: your-username/your-repo-name
repo_id:
category:
category_id:
mapping: pathname
term:
strict: 0
reactions_enabled: 1
emit_metadata: 0
theme: light
dark: dark
lang:
input_position: bottom
data_loading: lazy
landscape 主题举例:
/images/default.pngleft(靠左)| center(居中)| right(靠右)px】
true | falsetrue | false2 | 3 | 4 | 5left | rightArial | Helvetica | Tahoma | Sitka | Times New Roman | Courier New | Verdana | Georgia | Palatino | Garamond | Comic Sans MS | Trebuchet MS
楷体 | 等线 | 黑体 | 宋体 | 仿宋
1.1em 或 17px)utterances | gitalktrue | false。设置为 true 意味着记住访客选择的评论系统。true | falseutterances - 评论系统名,参考各评论系统定义即可
true | falsetrue | falsepathname | url | title | og:title | issue number | specific term
pathname - issue标题包含页面路径名。Utterances 会搜索标题包含页面路径名的issue。如果未找到匹配的议题,当有人首次发表评论时,Utterances 将自动创建一个。url - issue标题包含页面URL。Utterances 会搜索标题包含页面URL 的issue。如果未找到匹配的议题,当有人首次发表评论时,Utterances 将自动创建一个。title - issue标题包含页面标题。Utterances 会搜索标题包含页面标题的issue。如果未找到匹配的议题,当有人首次发表评论时,Utterances 将自动创建一个。og:title - issue标题包含页面 og:title。Utterances 会搜索标题包含页面 Open Graph 标题元数据的issue。如果未找到匹配的议题,当有人首次发表评论时,Utterances 将自动创建一个。issue number - 特定issue编号。您可以通过该编号配置 Utterances 以加载特定issue。不会自动创建issue。specific term - issue标题包含特定术语。您可以配置 Utterances 以搜索标题包含您配置的特定术语的issue。如果未找到匹配的议题,当有人首次发表评论时,Utterances 将自动创建一个,且该issue的标题将是您设置的术语。github-light | github-dark | preferred-color-scheme | github-dark-orange | icy-dark | dark-blue | photon-dark | boxy-lighttrue | falsetrue | falsepathname | url | title | issue number
pathname - issue的标签包含页面路径名。url - issue的标签包含页面URL。title - issue的标签包含页面标题。issue number - 特定issue编号。您可以通过该编号配置 Gitalk 以加载特定issue。zh-CN | zh-TW | en | es-ES | fr | rutrue | falsetrue | false<script>内容。Announcements | General | Ideas | Polls | Q&A | Show and tell<script>内容。pathname | url | title | og:title | specific
pathname - Discussion 的标题包含页面的 pathname。giscus 将查找标题中包含页面 URL 的 pathname 部分的 discussion。url - Discussion 的标题包含页面的 URL。giscus 将查找标题中包含页面 URL 的 discussion。title - Discussion 的标题包含页面的 <title>。giscus 将查找标题中包含页面的 <title> 标签的 discussion。og:title - Discussion 的标题包含页面的 og:title。giscus 将查找标题中包含页面的 <meta property="og:title">标签的 discussion。specific - 特别指定,需要搭配 term 配置属性使用。specific 时,该值必须配置,如下:
light | light_high_contrast | light_protanopia | light_tritanopia | dark | dark_high_contrast | dark_protanopia | dark_tritanopia | dark_dimmed | preferred_color_scheme | transparent_dark | noborder_light | noborder_dark | noborder_gray | cobalt | purple_darkwindow.navigator.language。 可选值:zh-CN | zh-TW | en | es-ES | fr | rubottom - 将评论输入框固定在页面的底部(评论列表下方)top - 将评论输入框固定在页面的顶部(评论列表上方)<iframe> 元素来完成的。将 themes/diversity 目录下的 _config.diversity.yml,添加到你的 Hexo 项目根目录
themes: [landscape,light,phase]
#ports: [5000,5001,5002]
hexo server 启动各主题对应的HTTP服务将 themes/diversity 目录下的 other 目录中的目录和文件复制或移动到你的 Hexo 项目根目录
themes/diversity 目录下的 languages 目录中的 zh-CN.yml 包含如下配置:
menu:
blog: 博客
theme: 主题
comment: 留言
button:
theme-default: 设为默认
cancel-defalut: 取消默认
theme-redirect: 主题直达
theme-source: 主题来源
back-to-top: 返回顶部
gritter:
title-theme: 主题【{0}】
text-configured: 已设置
text-canceled: 已取消
text-click-to-jump: 点击跳转
no-theme:
tip-text: 您还没有设置默认主题!点击下方按钮前往设置
btn-text: 主题选择
page:
contents: 目录
back_to_top: 回到顶部
last_updated: 上次更新:%s
loading-tips:
comment: 评论正在加载中...
introduction:
landscape: Hexo 中的一个全新的默认主题,需要 Hexo 2.4 或者 更高的版本。
phase: 通过 Phase,感受时间流逝,它是 Hexo 最美丽的主题。
light: Hexo 中的一个简约主题。
在你的 Hexo 项目根目录,添加 config 目录,为上述多主题列表中的每个主题添加一个对应主题名的配置目录,
并在该配置目录下添加对应的 _config.yml 【直接从你原来项目根目录下的 _config.yml 复制一份即可】,形如:
├─config │ ├─landscape │ │ ├─_config.yml │ ├─light │ │ ├─_config.yml │ ├─phase │ │ ├─_config.yml
修改上述各主题配置目录下的 _config.yml,以 landscape 举例:
_config.yml
- url: http://example.com
+ url: http://example.com/landscape
- public_dir: public
+ public_dir: public/landscape
- theme: other-theme
+ theme: landscape
在你的 Hexo 项目根目录下,我们依旧可以添加不同主题独立的 _config.[theme].yml 文件,更多了解请查看官方《配置》
针对不同主题,可在各自配置中启用分类和标签生成配置
category_generator:
enable_index_page: true
layout: category-index
per_page: 10
order_by: -date
true 【启用分类首页生成, 通常是 /categories/index.html]category-indextag_generator:
enable_index_page: true
layout: tag-index
per_page: 100
order_by: -date
true 【启用标签首页生成, 通常是 /tags/index.html]tag-index详细了解,请翻看 Huazie 的博客分类之 博客框架-Hexo 中的文章。