hexo _config.yml站点配置文件说明

快来打我* 2022-11-05 13:53 81阅读 0赞

site

  • title: 网站标题
    subtitle: ‘网站说明1’
    description: ‘网站说明2’
    keywords:
    author: 作者名
    language: zh-Hans
    timezone: ’ ’





































参数 描述
title 网站标题
subtitle 网站副标题
description 网站描述
keywords 网站的关键词。使用半角逗号 , 分隔多个关键词。
author 您的名字
language 网站使用的语言。对于简体中文用户来说,使用不同的主题可能需要设置成不同的值,请参考你的主题的文档自行设置,常见的有 zh-Hanszh-CN
timezone 网站时区。Hexo 默认使用您电脑的时区。请参考 时区列表 进行设置,如 America/New_York, Japan, 和 UTC 。一般的,对于中国大陆地区可以使用 Asia/Shanghai

其中,description主要用于SEO,告诉搜索引擎一个关于您站点的简单描述,通常建议在其中包含您网站的关键词。author参数用于主题显示文章的作者。

URL

  • url: https://账户名.github.io
    root: /
    permalink: :year/:month/:day/:title/
    permalink_defaults:
    pretty_urls:
    trailing_index: true
    trailing_html: true













































参数 描述 默认值
url 网址
root 网站根目录
permalink 文章的 永久链接 格式 :year/:month/:day/:title/
permalink_defaults 永久链接中各部分的默认值
pretty_urls 改写 permalink 的值来美化 URL
pretty_urls.trailing_index 是否在永久链接中保留尾部的 index.html,设置为 false 时去除 true
pretty_urls.trailing_html 是否在永久链接中保留尾部的 .html, 设置为 false 时去除 (对尾部的 index.html无效) true

提示:网站存放在子目录,这个情况要注意!!!

  • 如果您的网站存放在子目录中,例如 http://yoursite.com/blog,则请将您的 url 设为 http://yoursite.com/blog 并把 root 设为 /blog/
  • 一般的

    url: https://账户名.github.io
    root: /

    deploy:

    type: git

    repository: https://github.com/账户名/账户名.github.io.git

    branch: master

    (github仓库里面新建一个账户名.github.io的文件夹)

  • 提示中的情况

    url: https://账户名.github.io/blog/ (blog是github仓库新建的文件夹)
    root: /blog

    deploy:

    type: git

    repository: https://github.com/账户名/blog.git

    branch: master

    (github仓库里面新建一个blog的文件夹)

  • 补充

    比如,一个页面的永久链接是 http://example.com/foo/bar/index.html

    pretty_urls:
    trailing_index: false

    此时页面的永久链接会变为 http://example.com/foo/bar/

目录

  • source_dir: source

    public_dir: public

    tag_dir: tags

    archive_dir: archives

    category_dir: categories

    code_dir: downloads/code

    i18n_dir: :lang

    skip_render:



















































参数 描述 默认值
source_dir 资源文件夹,这个文件夹用来存放内容。 source
public_dir 公共文件夹,这个文件夹用于存放生成的站点文件。 public
tag_dir 标签文件夹 tags
archive_dir 归档文件夹 archives
category_dir 分类文件夹 categories
code_dir Include code 文件夹,source_dir 下的子目录 downloads/code
i18n_dir 国际化(i18n)文件夹 :lang
skip_render 跳过指定文件的渲染。匹配到的文件将会被不做改动地复制到 public 目录中。您可使用 glob 表达式来匹配路径。

例如:

  1. skip_render: "mypage/**/*"
  2. # 将会直接将 `source/mypage/index.html` 和 `source/mypage/code.js` 不做改动地输出到 'public' 目录
  3. # 你也可以用这种方法来跳过对指定文章文件的渲染
  4. skip_render: "_posts/test-post.md"
  5. # 这将会忽略对 'test-post.md' 的渲染

提示

如果您刚刚开始接触 Hexo,通常没有必要修改这一部分的值。

文章

  • new_post_name: :title.md # File name of new posts

    default_layout: post

    titlecase: false # Transform title into titlecase

    external_link:

    enable: true # Open external links in new tab

    field: site # Apply to the whole site

    exclude: ‘’

    filename_case: 0

    render_drafts: false

    post_asset_folder: false

    relative_link: false

    future: true

    highlight:

    enable: true

    line_number: true

    auto_detect: false

    tab_replace: ‘’

    wrap: true

    hljs: false















































































































参数 描述 默认值
new_post_name 新文章的文件名称 :title.md
default_layout 预设布局 post
auto_spacing 在中文和英文之间加入空格 false
titlecase 把标题转换为 title case false
external_link 在新标签中打开链接 true
external_link.enable 在新标签中打开链接 true
external_link.field 对整个网站(site)生效或仅对文章(post)生效 site
external_link.exclude 需要排除的域名。主域名和子域名如 www 需分别配置 []
filename_case 把文件名称转换为 (1) 小写或 (2) 大写 0
render_drafts 显示草稿 false
post_asset_folder 启动 Asset 文件夹 false
relative_link 把链接改为与根目录的相对位址 false
future 显示未来的文章 true
highlight 代码块的设置
highlight.enable 开启代码块高亮 true
highlight.auto_detect 如果未指定语言,则启用自动检测 false
highlight.line_number 显示行数 Enabling this option will also enable wrap option true
highlight.tab_replace 用 n 个空格替换 tabs;如果值为空,则不会替换 tabs ‘’
highlight.wrap Wrap the code block in `` true
highlight.hljs Use the hljs-* prefix for CSS classes false

相对地址

默认情况下,Hexo 生成的超链接都是绝对地址。例如,如果您的网站域名为 example.com,您有一篇文章名为 hello,那么绝对链接可能像这样:http://example.com/hello.html,它是绝对于域名的。相对链接像这样:/hello.html,也就是说,无论用什么域名访问该站点,都没有关系,这在进行反向代理时可能用到。通常情况下,建议使用绝对地址。

其他

分类 & 标签


























参数 描述 默认值
default_category 默认分类 uncategorized
category_map 分类别名
tag_map 标签别名

日期 / 时间格式

Hexo 使用 Moment.js 来解析和显示时间。


























参数 描述 默认值
date_format 日期格式 YYYY-MM-DD
time_format 时间格式 HH:mm:ss
use_date_for_updated 启用以后,如果 Front Matter 中没有指定 updatedpost.updated 将会使用 date 的值而不是文件的创建时间。在 Git 工作流中这个选项会很有用 true

分页





















参数 描述 默认值
per_page 每页显示的文章量 (0 = 关闭分页功能) 10
pagination_dir 分页目录 page

扩展


























参数 描述
theme 当前主题名称。值为false时禁用主题
theme_config 主题的配置文件。在这里放置的配置会覆盖主题目录下的 _config.yml 中的配置
deploy 部署部分的设置
meta_generator Meta generator 标签。 值为 false 时 Hexo 不会在头部插入该标签

发表评论

表情:
评论列表 (有 0 条评论,81人围观)

还没有评论,来说两句吧...

相关阅读