2020-04-20 02:20:30 +00:00
|
|
|
title: Icarus User Guide - Configuring the Theme
|
|
|
|
date: 2020-03-01
|
|
|
|
categories:
|
|
|
|
- Configuration
|
|
|
|
tags:
|
|
|
|
- Getting Started
|
|
|
|
- Icarus User Guide
|
|
|
|
language: en
|
|
|
|
toc: true
|
2020-08-24 06:58:52 +00:00
|
|
|
cover: /gallery/covers/vector_landscape_2.svg
|
|
|
|
thumbnail: /gallery/covers/vector_landscape_2.svg
|
2020-04-20 02:20:30 +00:00
|
|
|
---
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
Icarus' default theme configuration file is `_config.icarus.yml`.
|
2020-05-01 05:01:59 +00:00
|
|
|
It defines the global layout and style settings of the theme and controls external features such as plugins and widgets.
|
|
|
|
This article details the general configurations of the theme.
|
|
|
|
It also explains what configuration files are used and how Icarus generate and validate these configurations.
|
2020-04-20 02:20:30 +00:00
|
|
|
|
|
|
|
<!-- more -->
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
<article class="message message-immersive is-primary">
|
|
|
|
<div class="message-body">
|
2020-05-03 04:37:03 +00:00
|
|
|
<i class="fas fa-globe-asia mr-2"></i>This article is also available in
|
|
|
|
<a href="{% post_path zh-CN/Configuring-Theme %}">简体中文</a>.
|
2020-04-20 02:20:30 +00:00
|
|
|
</div>
|
2020-05-01 05:01:59 +00:00
|
|
|
</article>
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
## General Theme Configurations
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
### Configuration Version
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
This version code is related to and but not always the same as the theme version code.
|
|
|
|
Icarus uses it to determine whether to upgrade the default theme configuration file.
|
|
|
|
You should not change it by yourself.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
|
|
|
version: 4.0.0
|
2020-04-20 02:20:30 +00:00
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
### Theme Variant
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
Choose a skin for Icarus.
|
|
|
|
`"default"` and `"cyberpunk"` are supported values currently.
|
|
|
|
You can take a look at the Cyberpunk variant {% post_link demo/Cyberpunk "here" %}.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
variant: default
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Logo
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
Set the logo of your site.
|
|
|
|
It will display on the navigation bar and the footer.
|
|
|
|
The value of the `logo` can either be the path or URL to your logo image:
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
logo: /img/logo.svg
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-05-06 02:01:15 +00:00
|
|
|
or text if you set it like the following:
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
logo:
|
|
|
|
text: My Beautiful Site
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Favicon
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can specify the path or URL to your site's favicon in the `head` section.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
head:
|
|
|
|
favicon: /img/favicon.svg
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Open Graph
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can set up Open Graph in the `head` section.
|
|
|
|
You should leave most of the settings blank in the configuration file.
|
|
|
|
Only set those settings in the front-matter of your post if you need them.
|
|
|
|
Please refer to [Hexo documentation](https://hexo.io/docs/helpers.html#open-graph) for details on each setting.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml >folded %}
|
2020-04-20 02:20:30 +00:00
|
|
|
head:
|
|
|
|
open_graph:
|
|
|
|
# Page title (og:title) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
title:
|
|
|
|
# Page type (og:type) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
type: blog
|
|
|
|
# Page URL (og:url) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
url:
|
|
|
|
# Page cover (og:image) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
image:
|
|
|
|
# Site name (og:site_name) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
site_name:
|
|
|
|
# Page author (article:author) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
author:
|
|
|
|
# Page description (og:description) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
description:
|
|
|
|
# Twitter card type (twitter:card)
|
|
|
|
twitter_card:
|
|
|
|
# Twitter ID (twitter:creator)
|
|
|
|
twitter_id:
|
|
|
|
# Twitter Site (twitter:site)
|
|
|
|
twitter_site:
|
|
|
|
# Google+ profile link (deprecated)
|
|
|
|
google_plus:
|
|
|
|
# Facebook admin ID
|
|
|
|
fb_admins:
|
|
|
|
# Facebook App ID
|
|
|
|
fb_app_id:
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Google Structured Data
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can set up Google Structured Data in the `head` section.
|
|
|
|
You should leave most of the settings blank in the configuration file.
|
|
|
|
Only set those settings in the front-matter of your post if you need them.
|
|
|
|
Please refer to [Search for Developers](https://developers.google.com/search/docs/guides/intro-structured-data)
|
|
|
|
for details on each setting.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml >folded %}
|
2020-04-20 02:20:30 +00:00
|
|
|
head:
|
|
|
|
structured_data:
|
|
|
|
# Page title (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
title:
|
|
|
|
# Page description (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
description:
|
|
|
|
# Page URL (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
url:
|
|
|
|
# Page author (article:author) (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
author:
|
|
|
|
# Page images (optional)
|
|
|
|
# You should leave this blank for most of the time
|
|
|
|
image:
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Page Metadata
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can add custom `<meta>` tags to the generated HTML from the `meta` setting in the `head` section.
|
|
|
|
Each meta tag should appear as an item of the `meta` array.
|
2020-05-06 02:01:15 +00:00
|
|
|
The value of each `meta` item should be in the `<field_name>=<field_value>` format
|
2020-05-01 05:01:59 +00:00
|
|
|
with `field_name` and `field_value` represent the field and value of the `<meta>` tag respectively.
|
|
|
|
Separate the `<field_name>=<field_value>` pairs with `;` if the `<meta>` tag has multiple fields and values.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
head:
|
|
|
|
meta:
|
|
|
|
- 'name=theme-color;content=#123456'
|
|
|
|
- 'name=generator;content="Hexo 4.2.0"'
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### RSS
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can add a link to your RSS feed at the `rss` setting in the `head` section.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
head:
|
|
|
|
rss: /path/to/atom.xml
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Navigation Bar
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
The `navbar` section defines the menu items and links in the navigation bar.
|
|
|
|
You may put any menu item in the navigation bar by adding `<link_name>: <link_url>` to the `menu` setting.
|
|
|
|
To put links on the right side of the navigation bar, add `<link_name>: <link_url>` to the `links` setting.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
navbar:
|
|
|
|
# Naviagtion menu items
|
|
|
|
menu:
|
|
|
|
Home: /
|
|
|
|
Archives: /archives
|
|
|
|
Categories: /categories
|
|
|
|
Tags: /tags
|
|
|
|
About: /about
|
|
|
|
# Links to be shown on the right of the navigation bar
|
|
|
|
links:
|
|
|
|
GitHub: 'https://github.com'
|
|
|
|
Download on GitHub:
|
|
|
|
icon: fab fa-github
|
|
|
|
url: 'https://github.com/ppoffice/hexo-theme-icarus'
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can display a FontAwesome icon instead of text-only link with the following format:
|
2020-04-20 02:20:30 +00:00
|
|
|
|
|
|
|
{% codeblock "Link format" lang:yaml %}
|
|
|
|
<link_name>:
|
|
|
|
icon: <fontawesome_icon_class_name>
|
|
|
|
url: <link_url>
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Footer
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
The `footer` section defines the links on the right side of the page footer.
|
|
|
|
The link format is exactly the same as `links` in the `navbar` section.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
footer:
|
|
|
|
links:
|
|
|
|
Creative Commons:
|
|
|
|
icon: fab fa-creative-commons
|
|
|
|
url: 'https://creativecommons.org/'
|
|
|
|
Attribution 4.0 International:
|
|
|
|
icon: fab fa-creative-commons-by
|
|
|
|
url: 'https://creativecommons.org/licenses/by/4.0/'
|
|
|
|
Download on GitHub:
|
|
|
|
icon: fab fa-github
|
|
|
|
url: 'https://github.com/ppoffice/hexo-theme-icarus'
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
### Code Highlight
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
If you have enabled code highlighting in Hexo, you can customize the code blocks with `highlight` settings
|
|
|
|
in the `article` section.
|
|
|
|
Choose a theme from all themes listed under
|
|
|
|
[highlight.js/src/styles](https://github.com/highlightjs/highlight.js/tree/9.18.1/src/styles).
|
|
|
|
Then, copy the file name (without the `.css` extension) to the `theme` setting.
|
|
|
|
|
|
|
|
To hide the "copy" button of every code block, set `clipboard` to `false`.
|
|
|
|
If you wish to fold or unfold all code blocks, set the `fold` setting to `"folded"` or `"unfolded"`.
|
|
|
|
You can also disable the folding feature by leaving the `fold` setting empty.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
article:
|
|
|
|
highlight:
|
|
|
|
# Code highlight themes
|
|
|
|
# https://github.com/highlightjs/highlight.js/tree/master/src/styles
|
|
|
|
theme: atom-one-light
|
|
|
|
# Show copy code button
|
|
|
|
clipboard: true
|
|
|
|
# Default folding status of the code blocks. Can be "", "folded", "unfolded"
|
|
|
|
fold: unfolded
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
Additionally, you can fold an individual code block in the Markdown file using the following syntax:
|
2020-04-20 02:20:30 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
{% codeblock "optional file name" lang:code_language_name >folded %}
|
|
|
|
...code block content...
|
|
|
|
{% endcodeblock %}
|
|
|
|
```
|
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
### Cover & Thumbnail
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
You can add a cover image to your post by adding the `cover` property in post's front-matter:
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
{% codeblock post.md lang:yaml %}
|
|
|
|
title: Getting Started with Icarus
|
|
|
|
cover: /gallery/covers/cover.jpg
|
|
|
|
---
|
|
|
|
Post content...
|
|
|
|
{% endcodeblock %}
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
Similarly, you may set the thumbnail of your post in the front-matter as well:
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
{% codeblock post.md lang:yaml %}
|
|
|
|
title: Getting Started with Icarus
|
|
|
|
thumbnail: /gallery/thumbnails/thumbnail.jpg
|
|
|
|
---
|
|
|
|
Post content...
|
|
|
|
{% endcodeblock %}
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
The thumbnail will show in the archive page as well as in the recent post widget.
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-08-24 06:58:52 +00:00
|
|
|
If you choose to use the image path in the front-matter, you need to ensure the path is absolute
|
|
|
|
or relative to the source directory of your site.
|
|
|
|
For example, to use `<your blog>/source/gallery/image.jpg` as a thumbnail image, you need to put
|
|
|
|
`thumbnail: /gallery/image.jpg` in the front-matter.
|
2020-04-20 02:20:30 +00:00
|
|
|
|
|
|
|
### Read Time
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
You can show a word counter and the estimated reading time of your article above the article title by
|
|
|
|
setting `readtime` to `true` in the `article` section.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
article:
|
|
|
|
readtime: true
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-08-29 20:44:57 +00:00
|
|
|
### Article Licensing
|
|
|
|
|
|
|
|
You can show a section at the end of your posts/pages describing the licensing of your work.
|
|
|
|
Both text and icons are accepted as license links.
|
|
|
|
This configuration is the same as `links` in the navigation bar or the footer:
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-08-29 20:44:57 +00:00
|
|
|
article:
|
|
|
|
# Article licensing block
|
|
|
|
licenses:
|
|
|
|
Creative Commons:
|
|
|
|
icon: fab fa-creative-commons
|
|
|
|
url: 'https://creativecommons.org/'
|
|
|
|
'CC BY-NC-SA 4.0': 'https://creativecommons.org/licenses/by-nc-sa/4.0/'
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-04-20 02:20:30 +00:00
|
|
|
### Sidebar
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
To make a sidebar fixed when you scroll the page, set the `sticky` setting of that sidebar to `true` in
|
|
|
|
the `sidebar` section.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-04-20 02:20:30 +00:00
|
|
|
sidebar:
|
|
|
|
left:
|
|
|
|
sticky: false
|
|
|
|
right:
|
|
|
|
sticky: true
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
### Other Configurations
|
2020-05-01 05:01:59 +00:00
|
|
|
|
|
|
|
You can refer to the [Icarus User Guide](/hexo-theme-icarus/tags/Icarus-User-Guide/) to learn more about
|
|
|
|
third-party plugins, widgets, and CDN provider configurations.
|
|
|
|
|
|
|
|
|
|
|
|
## Configuration Files and Priority
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
Apart from the default theme configuration file `_config.icarus.yml`, Icarus also looks at the following
|
2020-05-01 05:01:59 +00:00
|
|
|
locations for alternative configurations:
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
- The site configuration file at `_config.yml`
|
|
|
|
- Layout configuration files at `_config.post.yml` and `_config.page.yml`
|
2020-05-01 05:01:59 +00:00
|
|
|
- Post/page's [front-matter](https://hexo.io/docs/front-matter.html)
|
2020-08-29 22:38:49 +00:00
|
|
|
- (Deprecated) Legacy theme configuration file at `themes/icarus/_config.yml`
|
|
|
|
- (Deprecated) Legacy layout configuration file at `themes/icarus/_config.post.yml` and `themes/icarus/_config.page.yml`
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
### Layout Configuration Files
|
2020-04-20 02:20:30 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
Layout configuration files follow the same format and definitions as theme configuration files.
|
|
|
|
The configurations in `_config.post.yml` apply to all posts, and those in `_config.page.yml` apply to all custom pages.
|
|
|
|
They both override configurations in theme configuration files.
|
|
|
|
|
|
|
|
For example, you can adopt a two-column layout for all posts in `_config.post.yml`:
|
|
|
|
|
|
|
|
{% codeblock _config.post.yml lang:yaml %}
|
2020-05-01 05:01:59 +00:00
|
|
|
widgets:
|
|
|
|
-
|
|
|
|
type: recent_posts
|
|
|
|
position: left
|
|
|
|
-
|
|
|
|
type: categories
|
2020-08-29 22:38:49 +00:00
|
|
|
position: left
|
2020-05-01 05:01:59 +00:00
|
|
|
-
|
|
|
|
type: tags
|
2020-08-29 22:38:49 +00:00
|
|
|
position: left
|
2020-05-01 05:01:59 +00:00
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
while keeping a three-column layout in all other pages:
|
|
|
|
|
|
|
|
{% codeblock _config.icarus.yml lang:yaml %}
|
2020-05-01 05:01:59 +00:00
|
|
|
widgets:
|
|
|
|
-
|
|
|
|
type: recent_posts
|
|
|
|
position: left
|
|
|
|
-
|
|
|
|
type: categories
|
2020-08-29 22:38:49 +00:00
|
|
|
position: right
|
2020-05-01 05:01:59 +00:00
|
|
|
-
|
|
|
|
type: tags
|
2020-08-29 22:38:49 +00:00
|
|
|
position: right
|
2020-05-01 05:01:59 +00:00
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
### Post/Page Front-matter
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
If you wish to override theme configurations only for a certain post/page, you can set them in the front-matter
|
|
|
|
of that post/page.
|
2020-05-01 05:01:59 +00:00
|
|
|
For example, you can change the code block highlight theme of a single post by setting it in that post's
|
|
|
|
front-matter like the following:
|
|
|
|
|
|
|
|
{% codeblock source/_post/some-post.md lang:yaml %}
|
|
|
|
title: My first post
|
|
|
|
date: '2015-01-01 00:00:01'
|
|
|
|
article:
|
|
|
|
highlight:
|
|
|
|
theme: atom-one-dark
|
|
|
|
---
|
|
|
|
# Some Post
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
The above setting will always override the `article.highlight` in `_config.post.yml` and `_config.icarus.yml`
|
2020-05-01 05:01:59 +00:00
|
|
|
for that post.
|
2020-08-29 22:38:49 +00:00
|
|
|
This layered configuration scheme is handy for differentiating page customizations and optimizations
|
2020-05-01 05:01:59 +00:00
|
|
|
for different audiences.
|
2020-08-29 22:38:49 +00:00
|
|
|
For instance, you can enable faster CDNs or a localized comment service based on the country and language
|
2020-05-01 05:01:59 +00:00
|
|
|
of your page viewers.
|
2020-08-29 22:38:49 +00:00
|
|
|
|
|
|
|
However, it should be noted that post or page attributes defined by Hexo will not override the theme
|
|
|
|
configurations from the front-matter.
|
|
|
|
Examples are `title`, `date`, `updated`, `comments`, `layout`, `source`, `photos`, and `excerpt`.
|
|
|
|
|
|
|
|
### Site Configuration File
|
|
|
|
|
|
|
|
All configuration sources listed above, including theme configuration files, layout configuration files,
|
|
|
|
and post/page front-matter, will override the site configuration file only for configurations
|
|
|
|
used by Icarus.
|
|
|
|
For instance, `title` in the `_config.icarus.yml` will override `title` in the `_config.yml`, but
|
2020-05-01 05:01:59 +00:00
|
|
|
`new_post_name` will not since it is not used by Icarus.
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
Also, the `theme_config` option in the site configuration file will merge with and override theme
|
|
|
|
configurations from theme configuration files.
|
|
|
|
However, using this option is highly discouraged.
|
|
|
|
|
|
|
|
### Conclusion
|
|
|
|
|
2020-05-06 02:01:15 +00:00
|
|
|
In conclusion, the scopes of the configuration sources and their priorities are:
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-05-06 02:01:15 +00:00
|
|
|
- For a certain post or page
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
- Post/Page front-matter overrides all following sources.
|
|
|
|
- Layout configuration files override all following sources.
|
|
|
|
- `theme_config` option in the site configuration file overrides all following sources.
|
|
|
|
- Theme configuration files override all following sources.
|
|
|
|
- The site configuration file.
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-05-06 02:01:15 +00:00
|
|
|
- For all posts or pages
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
- Layout configuration files override all following sources.
|
|
|
|
- `theme_config` option in the site configuration file overrides all following sources.
|
|
|
|
- Theme configuration files override all following sources.
|
|
|
|
- The site configuration file.
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-05-06 02:01:15 +00:00
|
|
|
- For all posts, pages, and index pages
|
2020-05-01 05:01:59 +00:00
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
- `theme_config` option in the site configuration file overrides all following sources.
|
|
|
|
- Theme configuration files override all following sources.
|
|
|
|
- The site configuration file.
|
2020-05-01 05:01:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Configuration Generation and Validation
|
|
|
|
|
2020-08-29 22:38:49 +00:00
|
|
|
All Icarus theme configurations are written in [YAML language](https://yaml.org/).
|
|
|
|
Icarus will automatically generate the default configuration file `_config.icarus.yml` from a set of
|
|
|
|
[JSON schemas](https://json-schema.org/) if it does not exist.
|
|
|
|
That's why you don't see an example configuration file (such as `_config.yml.example`) under the theme directory.
|
|
|
|
Most of the JSON schemas are in the `<icarus_directory>/include/schema` directory, while the others are
|
2020-05-01 05:01:59 +00:00
|
|
|
in the [ppoffice/hexo-component-inferno](https://github.com/ppoffice/hexo-component-inferno) repository.
|
|
|
|
You can attach the `--icarus-dont-generate-config` flag to your `hexo` commands to prevent automatic configuration
|
|
|
|
generation.
|
|
|
|
|
|
|
|
The theme also validates your configurations against these schemas every time you execute a `hexo` command.
|
|
|
|
If anything goes wrong during the validation, Icarus will print out the exact location of the misconfiguration
|
2020-05-06 02:01:15 +00:00
|
|
|
and its error type.
|
2020-05-01 05:01:59 +00:00
|
|
|
For example, the following messages tell us that the value of the `logo` setting should be either a string or an
|
|
|
|
object, instead of an integer.
|
|
|
|
You may skip the validation by appending the `--icarus-dont-check-config` flag to your `hexo` commands, but it is
|
|
|
|
not recommended to do so.
|
|
|
|
|
|
|
|
{% codeblock "hexo log" %}
|
|
|
|
INFO === Checking package dependencies ===
|
|
|
|
INFO === Checking the configuration file ===
|
|
|
|
WARN Configuration file failed one or more checks.
|
|
|
|
WARN Icarus may still run, but you will encounter unexcepted results.
|
|
|
|
WARN Here is some information for you to correct the configuration file.
|
|
|
|
WARN [
|
|
|
|
{
|
|
|
|
keyword: 'type',
|
|
|
|
dataPath: '.logo',
|
|
|
|
schemaPath: '#/properties/logo/type',
|
|
|
|
params: { type: 'string,object' },
|
|
|
|
message: 'should be string,object'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
{% endcodeblock %}
|
|
|
|
|
|
|
|
Additionally, Icarus will execute migration scripts to upgrade the default theme configuration file to the newest
|
|
|
|
version if it is not.
|
2020-08-29 22:38:49 +00:00
|
|
|
These scripts are in the `<icarus_directory>/include/migration` directory.
|
2020-05-01 05:01:59 +00:00
|
|
|
You may disable the upgrade by appending the `--icarus-dont-upgrade-config` flag to your `hexo` commands.
|
|
|
|
Finally, Icarus will also check the Node.js package dependencies and remind you to install them if you haven't.
|
2020-04-20 02:20:30 +00:00
|
|
|
|
|
|
|
|
2020-05-01 05:01:59 +00:00
|
|
|
<article class="message message-immersive is-warning">
|
|
|
|
<div class="message-body">
|
2020-05-03 04:37:03 +00:00
|
|
|
<i class="fas fa-question-circle mr-2"></i>Something wrong with this article?
|
|
|
|
Click <a href="https://github.com/ppoffice/hexo-theme-icarus/edit/site/source/_posts/en/Configuring-Theme.md">here</a>
|
|
|
|
to submit your revision.
|
2020-04-20 02:20:30 +00:00
|
|
|
</div>
|
2020-05-01 05:01:59 +00:00
|
|
|
</article>
|
2020-04-20 02:20:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
<a style="background-color:black;color:white;text-decoration:none;padding:4px 6px;font-size:12px;line-height:1.2;display:inline-block;border-radius:3px" href="https://www.vecteezy.com/free-vector/vector-landscape" target="_blank" rel="noopener noreferrer" title="Vector Landscape Vectors by Vecteezy"><span style="display:inline-block;padding:2px 3px"><svg xmlns="http://www.w3.org/2000/svg" style="height:12px;width:auto;position:relative;vertical-align:middle;top:-1px;fill:white" viewBox="0 0 32 32"><path d="M20.8 18.1c0 2.7-2.2 4.8-4.8 4.8s-4.8-2.1-4.8-4.8c0-2.7 2.2-4.8 4.8-4.8 2.7.1 4.8 2.2 4.8 4.8zm11.2-7.4v14.9c0 2.3-1.9 4.3-4.3 4.3h-23.4c-2.4 0-4.3-1.9-4.3-4.3v-15c0-2.3 1.9-4.3 4.3-4.3h3.7l.8-2.3c.4-1.1 1.7-2 2.9-2h8.6c1.2 0 2.5.9 2.9 2l.8 2.4h3.7c2.4 0 4.3 1.9 4.3 4.3zm-8.6 7.5c0-4.1-3.3-7.5-7.5-7.5-4.1 0-7.5 3.4-7.5 7.5s3.3 7.5 7.5 7.5c4.2-.1 7.5-3.4 7.5-7.5z"></path></svg></span><span style="display:inline-block;padding:2px 3px">Vector Landscape Vectors by Vecteezy</span></a>
|