This is my third day of the August Challenge, a description and example of the configuration file content in the Hexo framework.

_config.yml – Site configuration file

The site configuration file, which appears frequently in various Hexo-related tutorials, refers to the file _config.yml in the root directory of Hexo.

Refer to the official document for details.

  • Note: Configure each item in the processIn English the colonAnd then you need oneThe blank space.

Site – web Site

parameter describe
title Site title
subtitle Site subtitle
description Website description
keywords Keywords on the site. Use the half-corner comma.Separate multiple keywords.
author Your name
language Language of the site (You are advised to set zh-hans to facilitate stable translation)
timezone Site time zone. By default, Hexo uses your computer’s time zone. Please refer to theList of time zonesSettings, such asAmerica/New_York.Japan, andUTC. Generally, for mainland China can be usedAsia/Shanghai.
  • This part is the part that we need to set up when we just set up the website. It is suggested to modify it. Take my site configuration as an example:
# Site
title: See also pale haze
subtitle: 'www.zywvvd.com'
description: 'Stay hungury ! Stay foolish !'
keywords: 'Artificial intelligence, Deep learning, personal blogging'
author: Yiwei Zhang
language: zh-Hans
timezone: Asia/Shanghai
Copy the code

URL – web site

parameter describe The default value
url The url
root Site root
permalink The articlePermanent linkformat :year/:month/:day/:title/
permalink_defaults The default values for the sections in the permalink
pretty_urls rewritepermalinkTo beautify the URL
pretty_urls.trailing_index Whether to keep the tail in the permalinkindex.html, is set tofalseWhen removing true
pretty_urls.trailing_html Whether to keep the tail in the permalink.html, is set tofalseTo remove (Of the tailindex.htmlinvalid)
  • The URL and root need to be associated with the mounted server directory

Modify the site configuration file and fill in the url Settings:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://github.com/
      
       /
       
        .github. IO
       
root: > / < making account. Making. IO /
Copy the code
  • Modify the article permalink

The default path is similar: www.zywvvd.com/2020/02/27/…

This is because the article link configuration permalink default value: year / : : month/day / : title /

Students who do not like this form of link can customize it, for example:

permalink: :category/:title/
Copy the code

You can use the following variables and all the properties in front-matter.

variable describe
:year Year of publication (4 digits)
:month Month in which the article was published (2-digit)
:i_month The month in which the article was published (remove the beginning zero)
:day Date of publication (2-digit)
:i_day The publication date of the article (remove the opening zero)
:hour Hours at publication (2-digit)
:minute Minutes at publication (2 digits)
:title The file name
:post_title The article title
:id The article ID (not persistent across cache reset)
:category Classification. If the article is not classified, yesdefault_categoryConfiguration information.

Directory – the Directory

parameter describe The default value
source_dir Resource folder. This folder is used to store content. source
public_dir The public folder where the generated site files are stored. public
tag_dir Label folder tags
archive_dir Archive folder archives
category_dir Classified folder categories
code_dir Include Code folder,source_dirSubdirectories under downloads/code
i18n_dir Internationalization (I18N) folder :lang
skip_render Skip the rendering of the specified file. Matched files will be copied unchanged topublicDirectory. You can useThe glob expressionTo match the path.

Writing articles –

parameter describe The default value
new_post_name The file name of the new article :title.md
default_layout The default layout post
auto_spacing Add Spaces between Chinese and English false
titlecase Convert the title to a Title case false
external_link Open the link in a new TAB true
external_link.enable Open the link in a new TAB true
external_link.field For the entire site (site) or only for articles (post) to take effect site
external_link.exclude Domain names that need to be excluded. Primary domain name and subdomain name such aswwwTo be configured separately []
filename_case Converts the file name to (1) lowercase or (2) uppercase 0
render_drafts According to the draft false
post_asset_folder Start theAsset folder(It is recommended to set this parameter to True.) false
relative_link Change the link to the address relative to the root directory false
future Displays future articles true
highlight Code block Settings
highlight.enable Turns on code block highlighting true
highlight.auto_detect If no language is specified, automatic detection is enabled false
highlight.line_number According to the number of rowsEnabling this option will also enable wrap option true
highlight.tab_replace Replace tabs with n Spaces; If the value is empty, the tabs will not be replaced ' '
highlight.wrap Wrap the code block in ` ` true
highlight.hljs Use the hljs-* prefix for CSS classes false
  • post_asset_folderIf this parameter is set to true, a folder with the same name will be created when new articles are created, which is convenient for resource management such as blog pictures

Category & Tag – Category & Tag

parameter describe The default value
default_category The default classification uncategorized
category_map Classification of alias
tag_map Label the alias

Date/Time format – Date/Time format

Hexo uses moment.js to parse and display the time.

parameter describe The default value
date_format The date format YYYY-MM-DD
time_format Time format HH:mm:ss
use_date_for_updated When enabled, if not specified in Front Matterupdated.post.updatedWill usedateInstead of the creation time of the file. This option can be useful in Git workflows true

Pagination – paging

parameter describe The default value
per_page Number of articles displayed per page (0 = Turn paging off) 10
pagination_dir Page directory page

Extensions – extension

parameter describe
theme Name of the current topic. A value offalseDisable topic when
theme_config The configuration file for the topic. The configuration placed here overrides those in the topic directory_config.ymlThe configuration in
deploy Settings for the deployment section
meta_generator Meta generatorThe label. A value offalseHexo does not insert the tag in the header
  • Change the theme value to the theme name when changing a theme

Include/Exclude file(s) – Includes or excludes directories and files

In the Hexo configuration file, you can set include/exclude to allow Hexo to process or ignore certain directories and folders. You can use glob expressions to match directories and files.

include and exclude options only apply to the source/ folder, whereas ignore option applies to all folders.

parameter describe
include By default, Hexo ignores hidden files and folders (including names with an underscore and).The beginning of the file and folder, Hexo_posts_dataEtc.). Setting this field will cause Hexo to process them and copy them tosourceDirectory.
exclude Hexo ignores these files and directories
ignore Ignore files/folders