This article is translated from ChatGPT.
📚 Table of Contents
🚀 Get Started - 📑 Theme Pages - 📌 Theme Configuration - ⚔️ Tag Plugins - ❓ Q&A - ⚡️ Advanced Tutorials
Quick Read of Configuration Files
You can quickly understand all the configuration comments, making your configuration files more convenient. If you encounter any unclear configurations, you can find more detailed information in this article.
1 | # -------------------------------------- |
Language
Modify Hexo's configuration file _config.yml
The default language is en
The theme supports the following languages:
- default (en)
- zh-CN (Simplified Chinese)
- zh-TW (Traditional Chinese)
- zh-HK (Traditional Chinese)
- ja (Japanese)
- ko (Korean)
1 |
|
Parameter | Explanation |
---|---|
logo | The website's logo, supports images, just input the image link |
display_title | Whether to display the website title, write true or false |
fixed | Whether to fix the status bar, write true or false |
Menu
1 | Home: / || fas fa-home |
Must be /xxx/
, followed by ||
to separate, then write the icon name.
If you do not wish to display an icon, the icon name can be omitted.
By default, subdirectories are expanded. If you want to hide them, add hide
inside the subdirectory.
1 | List||fas fa-list||hide: |
Note: The text of the navigation can be changed as desired.
For example:
1 | menu: |
Code Blocks
All features within code blocks are only applicable to Hexo's built-in code rendering.
If using a third-party renderer, it may not be effective.
1 | code_blocks: |
Parameter | Explanation |
---|---|
theme | Code highlight theme, options: darker / pale night / light / ocean / false |
macStyle | Whether to use Mac style |
height_limit | Code block height limit (unit: px), can be a number or false |
word_wrap | Whether to automatically wrap lines |
copy | Whether to show the copy button |
language | Whether to show the language label |
shrink | true: collapse code block / false: expand code block / none: expand code block and hide button |
fullpage | Whether to show the full page button |
Code Highlight Theme
Butterfly
supports 4 types of code highlight styles:
- darker
- pale night
- light
- ocean
If you need a MacOS style code highlight, you can set macStyle
to true
.
darker
pale night
light
ocean
macStyle
Starting from version 3.0, the theme supports custom code color themes.
To learn how to create a custom theme, refer to the following article:
Code Block Expand/Collapse
By default, code blocks are automatically expanded. You can set whether all code blocks are in a collapsed state, and they can be expanded by clicking >
.
- true All code blocks are collapsed and require clicking
>
to open. - false Code blocks are expanded and have a
>
click button. - none The
>
button is not displayed.
1 | highlight_shrink: true # Code blocks are collapsed and require clicking '>' to open. |
You can also add highlight_shrink
in the front-matter of the corresponding markdown file for a post/page to configure it independently.
When highlight_shrink
in the theme configuration file is set to true, you can add highlight_shrink: false
in the front-matter to configure the article to expand code blocks individually.
When highlight_shrink
in the theme configuration file is set to false, you can add highlight_shrink: true
in the front-matter to configure the article to collapse code blocks individually.
highlight_shrink: true
highlight_shrink: false
highlight_shrink: none
Code Word Wrap
By default, Hexo does not implement automatic word wrapping for code during compilation. If you prefer not to have a horizontal scrollbar within the code block area, you might want to enable this feature.
1 | code_word_wrap: true |
If you are using highlight for rendering, you need to find your site's Hexo configuration file _config.yml
and change line_number
to false
:
1 | highlight: |
If you are using prismjs for rendering, you need to find your site's Hexo configuration file _config.yml
and change line_number
to false
:
1 | prismjs: |
Before setting code_word_wrap
After setting code_word_wrap
Code Height Limit
Supported from version 3.7.0 and above
You can configure a height limit for code blocks. Any content exceeding this limit will be hidden, with a button to expand it shown.
1 | highlight_height_limit: false # unit: px |
Notes:
The unit is
px
. Add a number directly, such as 200.The actual height limit is
highlight_height_limit + 30 px
. An additional 30px is added to the limit to avoid showing the expand button when the code height exceeds the limit by just a little, resulting in no content being shown upon expansion.This does not apply to code blocks that are hidden (with CSS
display: none
).
Social Icons
Butterfly supports font-awesome v6 icons.
The format is icon name: url || descriptive text || color
1 | social: |
You can find the icon names here
PC:
!
Mobile:
Image Settings
Avatar
1 | avatar: |
Top Image
If you do not want to display the top image, you can directly configure disable_top_img: true
The order of obtaining the top image, if none are configured, the top image will not be displayed.
The order of obtaining the top image for pages:
Individually configured top_img
>default_top_img in the configuration file
The order of obtaining the top image for article pages:
Individually configured top_img
>cover
>default_top_img in the configuration file
Values in the configuration:
Configuration | Explanation |
---|---|
index_img | Top image for the homepage |
default_top_img | Default top image, displayed when the page's top_img is not configured |
archive_img | Top image for the archive page |
tag_img | Default top image for tag subpages |
tag_per_img | Top image for tag subpages, can configure a top_img for each tag |
category_img | Default top image for category subpages |
category_per_img | Top image for category subpages, can configure a top_img for each category |
For other pages (tags/categories/custom pages) and article pages, set the top_img
in the front-matter
of the corresponding markdown page.
All the above top_img can be configured with the following values:
Configuration Value | Effect |
---|---|
Leave empty | Display the default top_img (if any), otherwise display the default color (If the top_img of the article page is empty, the cover value will be displayed) |
img link | Link to the image, display the configured image |
Color ( HEX value - #0000FF RGB value - rgb(0,0,255) Color word - orange Gradient color - linear-gradient( 135deg, #E2B0FF 10%, #9F44D3 100%) ) | Corresponding color |
transparent | Transparent |
false | Do not display top_img |
tag_per_img
and category_per_img
are new in version 3.2.0, allowing individual configuration for tags and categories.
It is not recommended to configure different top images for each tag and category, as too many configurations will slow down the generation speed.
1 | tag_per_img: |
top_img: false
top_img: orange
top_img: 'linear-gradient(20deg, #0062be, #925696, #cc426e, #fb0347)'
Footer Background Image
1 | # Whether to display an image background for the footer (same as top_img) |
Configuration Value | Effect |
---|---|
Leave empty/false | Display the default color |
img link | Link to the image, display the configured image |
Color ( HEX value - #0000FF RGB value - rgb(0,0,255) Color word - orange Gradient color - linear-gradient( 135deg, #E2B0FF 10%, #9F44D3 100%) ) | Corresponding color |
transparent | Transparent |
true | Display the same as top_img |
true
Website Background
The default display is white, you can set an image or color
1 | # Color (HEX value/RGB value/Color word/Gradient color) |
Note: If your website root directory is not '/', when using local images, you need to add your root directory.
For example: if the website is https://yoursite.com/blog
, and you reference an image img/xx.png
, then set the background to /blog/img/xx.png
background:'#49B202'
Article Cover
In the markdown document of the article, add cover
in the Front-matter
and fill in the image address to be displayed.
If cover
is not configured, you can set a default cover to display.
If you do not want to display the cover on the homepage, you can set it to false
.
The order of obtaining the article cover: Front-matter cover
>default_cover in the configuration file
> false
1 | cover: |
Parameter | Explanation |
---|---|
index_enable | Whether to display the article cover on the homepage |
aside_enable | Whether to display the article cover in the aside |
archives_enable | Whether to display the article cover on the archive page |
default_cover | Default cover, can configure image link/color/gradient color etc. |
When multiple images are configured, one will be randomly selected as the cover. The configuration should be written as
1 | default_cover: |
Page Meta Display
This option is used to display related information about the article.
1 | post_meta: |
Home Page:
Parameter | Explanation |
---|---|
date_type | Displays the article's time, options: created / updated / both |
date_format | Configures whether to show the exact time or relative time, options: date / relative |
categories | Whether to display the article's categories |
tags | Whether to display the article's tags |
label | Whether to display text labels |
Post:
Parameter | Explanation |
---|---|
position | Position of the article page meta display, options: left / center |
date_type | Displays the article's time, options: created / updated / both |
date_format | Configures whether to show the exact time or relative time, options: date / relative |
categories | Whether to display the article's categories |
tags | Whether to display the article's tags |
label | Whether to display text labels |
Home Page
Post
date_format
is a new feature in version 3.2.0, allowing configuration of displaying exact or relative time.
Relative Time
Exact Time
Home Page
Home Page Top Image Size
By default, the display is full-screen, and site information is centered.
1 | # Home page settings |
Note: The value of index_top_img_height
cannot be a percentage. If both are not filled, default values will be used.
Example: when
1 | index_top_img_height: 400px |
Effect:
Website Subtitle
Set a subtitle or favorite motto to display on the home page.
1 | # Home page subtitle |
Home Page Card Layout
The theme supports seven types of card layouts for the home page
1 | index_layout: 3 |
配置值 | 解釋 |
---|---|
1 | Cover on the left, info on the right |
2 | Cover on the right, info on the left |
3 | Cover and info alternate between left and right |
4 | Cover on top, info on the bottom |
5 | Info displayed on the cover |
6 | Masonry layout - Cover on top, info on the bottom |
7 | Masonry layout - Info displayed on the cover |
Just fill in the number
, the default is 3
1: Cover on the left, info on the right
2: Cover on the right, info on the left
3: Cover and info alternate between left and right
4: Cover on top, info on the bottom
5: Info displayed on the cover
6: Masonry layout - Cover on top, info on the bottom
7: Masonry layout - Info displayed on the cover
Home Page Article Excerpts
Due to the theme's UI, home page article excerpts
only support automatic excerpts
and article description
.
1 | # Display the article introduction on homepage |
Parameter | Description |
---|---|
method | Method to display article content, four options available 1 - Display only description 2 - Prefer description, if not configured, display auto excerpt 3 - Display only auto excerpt 4 - Do not display article content |
length | Length of the auto excerpt, only needs to be configured when method is 2 or 3 |
Add description
in front-matter:
Article Page
TOC (Table of Contents)
Display TOC (Table of Contents) in the aside.
1 | toc: |
Attribute | Explanation |
---|---|
post | Whether to display TOC in article pages |
page | Whether to display TOC in regular pages |
number | Whether to show section numbers |
expand | Whether to expand the TOC |
style_simple | Simple mode (aside only shows TOC, only for articles) |
scroll_percent | Whether to show scroll progress percentage |
Toc PC
Toc Mobile
style_simple: true
Configuring for Specific Articles
Add toc_number
and toc
at the top of your article's md
file, and set them to true
or false
.
The theme will prioritize the Front-matter configuration of the article's Markdown file. If not configured, it will use the configuration in the theme configuration file.
Article Copyright
Display copyright and license information for your blog articles.
1 | post_copyright: |
Since Hexo 4.1
, URLs are decoded by default, so Chinese URLs will be decoded. Set decode: true
to display Chinese URLs.
If some articles (e.g., reprints) do not need to display copyright, you can set it individually in the article's Front-matter:
1 | copyright: false |
From version 3.0.0
, individual articles can have their own copyright information. Set it individually in the article's Front-matter:
1 | copyright_author: xxxx |
Copyright Display Screenshot
Article Donations/Sponsorship
At the end of each of your articles, you can add a donation button. You can configure the relevant QR codes yourself.
For those who haven't provided QR codes, you can configure an icon image for software and add the corresponding donation link. When users click the image, they'll be redirected to the link.
The link can be omitted, and it will default to the image link.
1 | reward: |
Article Edit Button
Display an edit button next to the article title. When clicked, it will redirect to the corresponding link.
1 | # Post edit |
Related Articles
When the article cover is set to false or no cover configuration is available, the background for related articles will display the theme color.
The related articles recommendation is based on the tags associated with each article.
1 | related_post: |
Article Pagination Buttons
When the article cover is set to false or no cover configuration is available, the background for pagination will display the theme color.
You can configure the logic for pagination or disable pagination display altogether.
1 | # post_pagination |
Parameter | Explanation |
---|---|
post_pagination: false | Disable pagination buttons |
post_pagination: 1 | Next post links to older post |
post_pagination: 2 | Next post links to newer post |
Outdated Article Reminder
if you want to close the out-of-date reminder for certain articles, you can configure noticeOutdate: false
in the corresponding article's front-matter
to close it individually.
You can choose to display an outdated notice for articles based on their update time.
1 | # Displays outdated notice for a post |
Configuration | Explanation |
---|---|
enable | Enable article outdated notice |
style | Notice style: simple / flat |
limit_day | Set how many days before the notice appears (default: 365 days) |
position | Notice position: top / bottom |
message_prev | Custom message (prefix) |
message_next | Custom message (suffix) |
style: flat
style: simple
Footer
Blog Start Year
The since
option displays the starting year of your site. It appears at the bottom of the page.
1 | footer: |
Custom Footer Text
The custom_text
option allows you to add custom text to the footer. You can use HTML here to write statements or other content.
1 | custom_text: Hi, welcome to my <a href="https://butterfly.js.org/">blog</a>! |
For those who need to include an ICP (Internet Content Provider) number, you can also add it within the custom_text
:
1 | custom_text: <a href="ICP link"><img class="icp-icon" src="ICP image"><span>Record Number:xxxxxx</span></a> |
Aside
Aside Configuration
1 | aside: |
sort_order
is used to configure the order of each card. If not configured, it will follow the order in the theme configuration file. The smaller the number, the higher its position.
Configuration | Explanation |
---|---|
enable | Whether to enable the sidebar |
hide | Whether to hide the sidebar by default |
button | Whether to show the button to hide/show the sidebar |
mobile | Whether to display the sidebar on mobile devices |
position | Sidebar position, left / right |
display.archive | Whether to display aside on the archive page |
display.tag | Whether to display aside on the tag page |
display.category | Whether to display aside on the category page |
card_author.enable | Whether to display the author card |
card_author.description | Author description information |
card_author.button.enable | Whether to display the button |
card_author.button.icon | Button icon, you can find the icon name here: https://fontawesome.com/icons?d=gallery&m=free |
card_author.button.text | Button text |
card_author.button.link | Button link |
card_announcement.enable | Whether to display the announcement card |
card_announcement.content | Announcement content (HTML tags can be used) |
card_recent_post.enable | Whether to display the recent posts card |
card_recent_post.limit | Number of posts to display, 0 for all |
card_recent_post.sort | Sorting method, date / updated |
card_newest_comments.enable | Whether to display the newest comments card |
card_newest_comments.limit | Number of comments to display, 0 for all |
card_newest_comments.storage | Storage time in minutes, saved to local storage to avoid re-fetching data on every refresh |
card_newest_comments.avatar | Whether to display avatars |
card_categories.enable | Whether to display the categories card |
card_categories.limit | Number of categories to display, 0 for all |
card_categories.expand | Whether to expand categories, none / true / false |
card_tags.enable | Whether to display the tags card |
card_tags.limit | Number of tags to display, 0 for all |
card_tags.color | Whether to display tag colors |
card_tags.orderby | Tag sorting method, random / name / length |
card_tags.order | Sorting method, 1 for ascending, -1 for descending |
card_archives.enable | Whether to display the archives card |
card_archives.type | Archive type, monthly / yearly |
card_archives.format | Archive display format, e.g., YYYY年MM月 |
card_archives.order | Sorting method, 1 for ascending, -1 for descending |
card_archives.limit | Number of archives to display, 0 for all |
card_post_series.enable | Whether to display the post series card |
card_post_series.series_title | Whether to display the series name |
card_post_series.orderBy | Sorting method, title / date |
card_post_series.order | Sorting method, 1 for ascending, -1 for descending |
card_webinfo.enable | Whether to display the website info card |
card_webinfo.post_count | Whether to display the number of posts |
card_webinfo.last_push_date | Whether to display the last update date |
card_webinfo.runtime_date | Display the website runtime, no need to enable, leave blank (if enabled, the format must be Month/Day/Year Time or Year/Month/Day Time) |
Currently, three comment systems - Livere, Facebook Comments, and Giscus do not support displaying the latest comments.
The latest comments are only loaded upon refreshing the page and do not update in real-time.
Due to API rate limits, to avoid excessive calls, the theme defaults to a storage duration of 10 minutes. This means, after a call, the data will be stored in localStorage, and refreshing the website within 10 minutes will only retrieve data from localStorage. After the 10-minute period, refreshing the page will call the API to load new data. (A storage
configuration was added in version 3.6.0, allowing for custom cache duration settings.)
position: left
position: right
card_tags color: false
card_tags color: true
aside button
website runtime
Newest Comments
Custom Add Aside Widget
Click to VisitBottom Right Buttons
Button Position
When the chat service is enabled, the chat service button may cover the bottom right buttons. You can set the position of these buttons. It's not recommended to adjust this unless necessary, the default is fine.
1 | # The distance between the bottom right button and the bottom (default unit: px) |
The default unit is px, just add the number directly.
Simplified and Traditional Chinese Conversion
The theme has a built-in simple conversion function between Simplified and Traditional Chinese, using a one-to-one pairing. In cases of multiple Traditional characters for a single Simplified character or vice versa, correct conversion may not occur. Please be aware.
After enabling, there will be a Simplified/Traditional conversion button at the bottom right.
1 | translate: |
Reading Mode
Reading mode removes content other than the article itself to avoid distractions during reading.
It only appears on article pages, with a reading mode button at the bottom right.
1 | readmode: true |
Dark Mode
There will be a dark mode button at the bottom right.
1 | # dark mode |
Parameter | Explanation |
---|---|
button | Whether to display the day/night mode switch button at the bottom right |
autoChangeMode | The mode of automatic switching autoChangeMode: 1 Changes according to the system, browsers/systems that do not support this will switch to light mode between the start and end times autoChangeMode: 2 Only switches to light mode between the start and end times, other times will be dark mode autoChangeMode: false Cancels automatic switching |
start | The start time for light mode |
end | The end time for light mode |
Scroll Status Percentage
1 | # show scroll percent in scroll-to-top button |
Button Sorting
You can sort the buttons at the bottom right corner.
Note: Do not duplicate
1 | # Don't modify the following settings unless you know how they work |
Global Configuration
Page Anchors
When page anchors are enabled, the page link will be updated according to the header ID as you scroll.
(Note: Each update will leave a history record. So if an article has many anchors, the web page's history record will be extensive.)
1 | # anchor |
Parameter | Explanation |
---|---|
auto_update | When scrolling, the URL will update according to the header ID. Default is false . |
click_to_scroll | Click the headline to scroll and update the anchor. Default is false . |
Image Captions
You can enable Figcaption to display image descriptions.
It will prioritize the title attribute of the image, followed by the alt attribute.
1 | photofigcaption: true |
Copy Configuration
You can configure whether the website content can be copied and whether to add copyright information to the copied content.
1 | copy: |
Parameter | Explanation |
---|---|
enable | Whether to enable copy permissions for the website |
copyright | Add copyright information after the copied content |
enable | Whether to enable adding copyright information |
limit_count | Word limit. When the copied text exceeds this limit, copyright information will be added to the copied content |
After adding copyright information
1 | Lorem ipsum dolor sit amet, test link consectetur adipiscing elit. Strong text pellentesque ligula commodo viverra vehicula. Italic text at ullamcorper enim. Morbi a euismod nibh. Underline text non elit nisl. Deleted text tristique, sem id condimentum tempus, metus lectus venenatis mauris, sit amet semper lorem felis a eros. Fusce egestas nibh at sagittis auctor. Sed ultricies ac arcu quis molestie. Donec dapibus nunc in nibh egestas, vitae volutpat sem iaculis. Curabitur sem tellus, elementum nec quam id, fermentum laoreet mi. Ut mollis ullamcorper turpis, vitae facilisis velit ultricies sit amet. Etiam laoreet dui odio, id tempus justo tincidunt id. Phasellus scelerisque nunc sed nunc ultricies accumsan. |
Word Count
To enable the word count feature, you need to install the hexo-wordcount
plugin.
Run npm install hexo-wordcount --save
or yarn add hexo-wordcount
in the hexo working directory.
1 | # Need to install the hexo-wordcount plugin |
Parameter | Explanation |
---|---|
post_wordcount | Display the word count on the article page |
min2read | Display the reading time on the article page |
total_wordcount | Display the total word count of the website in the sidebar |
Visitor Count (UV and PV) by busuanzi
Visit the official website of busuanzi for more information.
Due to the stability issues of busuanzi, there may be occasional access problems. Please be aware.
The visitor count on the article page is implemented through the busuanzi plugin. Some comment systems have their own visitor count feature, which can be enabled in the corresponding comment system configuration and will replace the busuanzi count.
1 | busuanzi: |
If you need to modify the CDN link of busuanzi, you can do so through the option
in the CDN
section of the theme configuration file
.
1 | CDN: |
Math
The theme supports two math formula rendering engines, MathJax
and KaTeX
. You can choose one according to your needs.
1 | # About the per_page |
Parameter | Explanation |
---|---|
use | Choose the math formula rendering engine, select mathjax or katex . Leave it empty if you don't need math formulas. |
per_page | Whether to load the math formula rendering engine on each page. If set to false , you need to add mathjax: true or katex: true in the article's Front-matter to load the math formula rendering engine for that article. |
hide_scrollbar | Whether to hide the scrollbar |
Do not use MathJax syntax in titles. The TOC may not display MathJax correctly and might show MathJax code instead.
It is recommended to use KaTeX for better results, as introduced below!
To enable MathJax, set use
to mathjax
.
MathJax configuration file
1 | mathjax: |
Parameter | Explanation |
---|---|
enableMenu | Enable the right-click menu |
tags | Choose whether to number equations. all for numbering all, ams for numbering only equations, none for no numbering |
Before using MathJax, you need to uninstall Hexo's markdown renderer and then install hexo-renderer-kramed.
Perform the following operations in your Hexo blog directory (not the Butterfly directory):
Install the plugin
1
2npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --saveConfigure the Hexo root directory configuration file
1
2
3
4
5
6
7
8kramed:
gfm: true
pedantic: false
sanitize: false
tables: true
breaks: true
smartLists: true
smartypants: true
Effect:
Do not use KaTeX syntax in titles. The TOC cannot display KaTeX correctly.
To enable KaTeX, set use
to katex
.
1 | katex: |
Parameter | Explanation |
---|---|
copy_tex | Enable the copy KaTeX formula function |
You do not need to add katex.min.js
to render math equations. Instead, you need to uninstall your previous Hexo markdown renderer and then install other plugins.
Uninstall the marked plugin and install hexo-renderer-markdown-it.
1 | npm un hexo-renderer-marked --save # If installed, uninstall it |
Configure the Hexo root directory _config.yml
.
1 | markdown: |
For other parameter configurations, please refer to the KaTeX official website.
Note: This method generates KaTeX without italics.
Uninstall the marked plugin and then install the new hexo-renderer-markdown-it-plus
:
1 | # Replace `hexo-renderer-kramed` or `hexo-renderer-marked` and other Hexo markdown renderers |
Note that hexo-renderer-markdown-it-plus
is no longer maintained, so we use @upupming/hexo-renderer-markdown-it-plus
. This fork uses @neilsustc/markdown-it-katex
, which is also used by the VSCode plugin Markdown All in One, so we can get the latest KaTeX features such as \tag{}
.
You can also control KaTeX settings through @neilsustc/markdown-it-katex
. All configurable options can be found at https://katex.org/docs/options.html. For example, if you want to disable the lengthy warning messages output by KaTeX on the command line, you can use the following configuration in the root directory _config.yml
to set strict
to false:
1 | markdown_it_plus: |
Of course, you can also use this feature to define some commonly used macros
.
Since KaTeX is faster and lighter, it does not have as many features as MathJax (such as the right-click menu). For those using MathJax, the theme also includes the copy function of KaTeX.
Search
The theme supports three search methods (algolia_search / local_search / docsearch). You can choose one or multiple search methods.
1 | search: |
Parameter | Description |
---|---|
use | Choose the search method you need; leave it empty if not needed |
placeholder | Placeholder text in the search box |
Remember to run hexo clean
If you use hexo-algoliasearch, make sure to configure the fields parameter with title
, permalink
, and content
.
Install hexo-algolia or hexo-algoliasearch and configure according to their documentation.
Set the
use
parameter in the theme configuration file toalgolia_search
.
Additional configuration:
1 | # Algolia Search |
Parameter | Description |
---|---|
hitsPerPage | Number of search results per page |
- Run Hexo.
Remember to run hexo clean
Install hexo-generator-searchdb or hexo-generator-search and configure according to their documentation.
Set the
use
parameter in the theme configuration file tolocal_search
.
Additional configuration:
1 | # Local Search |
Parameter | Description |
---|---|
preload | Preload search data on page load. If disabled, search data loads when the search button is clicked. |
top_n_per_article | Number of matched results to show per article, default is 1 |
unescape | Unescape HTML strings to readable text |
CDN | CDN URL for search data (default is local link) |
DocSearch is another search service provided by Algolia. For detailed application and usage, refer to the DocSearch documentation.
- Apply for DocSearch and obtain your
appId
,apiKey
, andindexName
. - Set the
use
parameter in the theme configuration file todocsearch
.
Additional configuration:
1 | # Docsearch |
Parameter | Description |
---|---|
appId | [Required] Your Algolia application ID |
apiKey | [Required] Your Algolia search API key |
indexName | [Required] Your Algolia index name |
option | [Optional] Additional DocSearch configuration. Refer to the documentation for details. |
Share
Only one sharing service can be selected.
The theme supports two sharing methods: sharejs
and addtoany
.
1 | share: |
Parameter | Description |
---|---|
use | Choose the sharing method: sharejs or addtoany . Leave it empty if sharing is not needed. |
If you're not familiar with sharejs, check out its documentation.
1 | # Share.js |
Refer to addtoany for usage instructions.
1 | addtoany: |
Comments System
The theme supports multiple comment systems. You can choose one according to your preference. You can also select dual comments by configuring two comment systems (the first one will be shown by default).
1 | comments: |
Parameter | Explanation |
---|---|
use | The comment system(s) to use (note: up to two systems, leave empty if not needed). Note: Dual comments cannot be Disqus and Disqusjs together due to shared ID conflicts. |
text | Whether to display the comment service name next to the button. |
lazyload | Whether to enable lazyload for comments. If enabled, the comment resources will load only when the comment section enters the viewport (comment count will not be displayed if lazyload is enabled). |
count | Whether to display the comment count at the top of the post. Livere, Giscus, and Utterances do not support comment count display. |
card_post_count | Whether to display the comment count on the homepage post cards. Gitalk, Livere, Giscus, and Utterances do not support comment count display. |
Single Comment
Dual Comments
Register on Disqus, configure your Disqus settings, and then enable it in the Butterfly
theme.
1 | disqus: |
Parameter | Explanation |
---|---|
shortname | Your Disqus shortname. You can create it here. |
Similar to Disqus, but can be used to display comments when Disqus is inaccessible in mainland China. Refer to Disqusjs for details.
1 | disqusjs: |
Parameter | Explanation |
---|---|
shortname | Your Disqus shortname. You can create it here. |
apikey | Your Disqus API Key. You can create it here. |
option | Optional configuration. |
Display when Disqus is inaccessible
Register on Livere, configure your Livere settings, and then enable it in the Butterfly
theme.
1 | livere: |
Parameter | Explanation |
---|---|
uid | Your Livere UID. You can create it here. |
The Livere UID can be found here:
Follow the Gitalk instructions to obtain your GitHub OAuth application client ID and secret, and check the related configuration instructions.
1 | gitalk: |
Parameter | Explanation |
---|---|
client_id | GitHub application's client ID. |
client_secret | GitHub application's client secret. |
repo | The repo to store issues. |
owner | The owner of the repo to store issues. |
admin | The owner and collaborators of the GitHub repository (users with write permissions to the repository). |
option | Optional configuration. |
Follow the Valine instructions to configure your LeanCloud application and check the relevant configuration instructions.
1 | valine: |
Parameter | Explanation |
---|---|
appId | The appId of your LeanCloud application. |
appKey | The appKey of your LeanCloud application. |
avatar | Avatar type, optional values: '' , mp , identicon , monsterid , wavatar , retro , robohash , blank , 404 . |
serverURLs | Custom LeanCloud server address. If you use a custom domain in mainland China, please fill in this item, otherwise, leave it empty. |
bg | Background image, can be an image URL like https://example.com/bg.jpg . |
visitor | Whether to display the article read count. |
option | Optional configuration. |
When visitor is enabled, the article read count on the article page will be provided by Valine, not Busuanzi.
Valine supports custom emojis from v1.4.5. If you need to configure them, set the emojiCDN
to your custom emoji CDN.
Also, create a JSON file valine.json
in the source/_data/
directory under your Hexo working directory, equivalent to Valine's emojiMaps
configuration. The valine.json
can be configured as follows:
valine.json
1 | { |
default_avatar
參數 | 效果 |
---|---|
empty(Default) | |
mp | |
identicon | |
monsterid | |
wavatar | |
retro | |
robohash | |
blank | |
404 |
Waline is a comment system derived from Valine that includes backend support. You can consider Waline as "With backend Valine".
Refer to the Waline documentation for detailed configuration.
1 | waline: |
Parameter | Description |
---|---|
serverURL | Waline server address |
bg | Background image URL, e.g., https://example.com/bg.jpg |
pageview | Whether to show article view count |
option | Optional configuration |
When pageview is enabled, the article view count will be provided by Waline instead of Busuanzi.
Like Gitalk, Utterances is a comment tool based on GitHub issues but with relatively fewer permissions required. Refer to Utterances documentation for details.
1 | utterances: |
Parameter | Description |
---|---|
repo | GitHub repository full name, e.g., owner/repo |
issue_term | Label used to identify issues, options: pathname/url/title/og:title |
light_theme | Light theme, options: github-light , github-dark , github-dark-orange , icy-dark , dark-blue , photon-dark |
dark_theme | Dark theme, options: github-light , github-dark , github-dark-orange , icy-dark , dark-blue , photon-dark |
Facebook Comments
is a plugin provided by Facebook, requiring users to log in with Facebook to comment.
1 | # Facebook Comments Plugin |
Parameter | Description |
---|---|
app_id | Facebook App ID, which can be created here |
user_id | Optional, Facebook User ID for managing comments |
pageSize | Number of comments to display |
order_by | Comment sorting method: social/time/reverse_time |
lang | Language |
Twikoo
is a simple, secure, and serverless comment system for static websites, based on Tencent Cloud Development.
For detailed configuration, please refer to the Twikoo documentation.
你只需要把獲取到的 環境ID (envId)
填寫到配置上去就行
1 | twikoo: |
Parameter | Description |
---|---|
envId | Environment ID |
region | Environment region, default is ap-shanghai . If your region is different, specify here. |
visitor | Whether to display article view count |
option | Optional configuration |
When visitor is enabled, the article view count will be provided by Twikoo instead of Busuanzi.
A comment system based on GitHub Discussions.
1 | # Giscus |
Parameter | Description |
---|---|
repo | GitHub repository full name, e.g., owner/repo |
repo_id | GitHub repository ID |
category_id | GitHub repository category ID |
option | Optional configuration |
Refer to the Giscus documentation for details.
Remark42 is a comment system that only supports self-hosting.
For detailed setup, refer to Installation | Remark42.
1 | remark42: |
Parameter | Description |
---|---|
host | Your Host URL |
siteId | Your Site ID |
option | Optional configuration |
Artalk is a comment system that only supports self-hosting.
For detailed setup, refer to Artalk | Self-hosted Comment System.
1 | artalk: |
Parameter | Description |
---|---|
server | Your Server URL |
site | Your Site ID |
visitor | Whether to display article view count |
option | Optional configuration |
When visitor is enabled, the article view count will be provided by Artalk instead of Busuanzi.
Online Chat
The theme includes several online chat tools. You can choose to enable one to facilitate communication with your visitors.
1 | chat: |
Parameter | Description |
---|---|
use | Choose the chat tool to use, options are chatra /tidio /crisp |
rightside_button | Enable the chat button at the bottom right corner |
button_hide_show | Hide chat button when scrolling down, show when scrolling up |
These tools provide a button to open/close the chat window. The theme also provides a custom button that will appear in the bottom right corner. Just enable the rightside_button
.
To avoid affecting user experience, the theme offers a button_hide_show
configuration. Set to true
to show the chat button only when scrolling up.
To enable Chatra, set the chat
configuration use
to chatra
.
Configure Chatra by getting the Public key
.
- Open Chatra and sign up.
- Find the
Public key
inPreferences
.
1 | # chatra |
You can customize Chatra's style in Chat Widget
.
Demo
To enable Tidio, set the chat
configuration use
to tidio
.
Configure Tidio by getting the Public key
.
- Open Tidio and sign up.
- Find the
Public key
inPreferences > Developer
.
1 | # tidio |
You can customize Tidio's style in Channels
.
Demo
To enable Crisp, set the chat
configuration use
to crisp
.
Configure Crisp by getting the Website ID
.
- Open Crisp and sign up.
- Find the
Website ID
.
1 | # crisp |
Analytics
Log in to the Baidu Analytics official website.
Locate your Baidu Analytics code.
- Modify the
theme configuration file
:
1 | baidu_analytics: your_code |
Log in to the Google Analytics official website.
Find your Google Analytics tracking ID.
- Modify the
theme configuration file
:
1 | google_analytics: your_code # usually starts with `UA-` |
- Log in to the Cloudflare Analytics official website.
- Locate the
JavaScript Snippet
. - Find your
token
.
Modify the
theme configuration file
:1
2
3# Cloudflare Analytics
# https://www.cloudflare.com/zh-tw/web-analytics/
cloudflare_analytics:
Log in to the Clarity official website.
Create a
PROJECT
.Find your
ID
.
Modify the
theme configuration file
:1
2
3# Microsoft Clarity
# https://clarity.microsoft.com/
microsoft_clarity:
Advertisements
The theme integrates Google Ads (Auto Ads).
1 | google_adsense: |
The theme reserves three spots for inserting ads: after every three articles on the homepage, after the aside announcement, and after the post donation section. Fill in the HTML code in the corresponding position.
1 | ad: |
例如:
1 | index: <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="xxxxxxxxxxxx" data-ad-client="ca-pub-xxxxxxxxxx" data-ad-slot="xxxxxxxxxx"></ins><script>(adsbygoogle=window.adsbygoogle||[]).push({})</script> |
Website Verification
If you need search engines to index your site, you may need to log in to the corresponding search engine management platform for submission. Verification codes can be obtained from each management platform.
1 | site_verification: |
Beautify / Effect
Custom Theme Colors
You can modify most UI colors.
Edit the theme configuration file
, for example:
Color values must be enclosed in double quotes, like "#000"
instead of #000
. Otherwise, an error will occur during the build process!
1 | theme_color: |
Parameter | Description |
---|---|
main | Main theme color |
paginator | Paginator color |
button_hover | Button hover color |
text_selection | Text selection color |
link_color | Link color |
meta_color | Article metadata color |
hr_color | Horizontal rule color |
code_foreground | Code foreground color |
code_background | Code background color |
toc_color | Table of contents color |
blockquote_padding_color | Blockquote padding color |
blockquote_background_color | Blockquote background color |
scrollbar_color | Scrollbar color |
meta_theme_color_light | Light mode theme color |
meta_theme_color_dark | Dark mode theme color |
Justify Text Alignment
You can set text to be justified, except for the last line.
1 | # Stretches the lines so that each line has equal width |
text_align_justify: false
text_align_justify: true
Black Mask
To avoid overly bright images making text unreadable, a black mask is added to header
and footer
by default.
1 | # Add a mask to the header and footer |
Page Load Animation (Preloader)
When entering a webpage, due to loading speed issues, the top_img image may appear fragmented, or the webpage may not load fully, resulting in a wait time. Enabling the preloader will show a loading animation, which will disappear once the page is fully loaded.
The theme supports the loading animation of pace.js, see pace.js for details.
1 | # Loading Animation |
fullpage-loading
Page Beautification
It changes the styles of ol, ul, h1-h5.
field
configuration applies to:
post
Applies only to the post pagesite
Applies to the entire site
1 | # Beautify page display |
Parameter | Description |
---|---|
enable | Enable beautification |
field | Area to be beautified |
title-prefix-icon | Prefix icon for titles |
title-prefix-icon-color | Color of the prefix icon |
title-prefix-icon
is the Unicode value of the fontawesome icon.
Beautification disabled
Beautification enabled
Custom Fonts and Font Sizes
Global Fonts
You can set the font-family for the entire site.
If no configuration is needed, leave it empty.
1 | # Global font settings |
Parameter | Description |
---|---|
global-font-size | Global font size |
code-font-size | Code font size |
font-family | Global font family |
code-font-family | Code font family |
Blog Title Font
You can set the font-family for the site title and subtitle.
If no configuration is needed, leave it empty.
If no web font is needed, leave font_link
empty.
1 | # Font settings for the site title and site subtitle |
Parameter | Description |
---|---|
font_link | Link to the web font |
font-family | Font family for the site title |
Typing Effect
Typing effect activate-power-mode.
1 | # Typewriter Effect |
Parameter | Description |
---|---|
enable | Enable typing effect |
colorful | Enable particle animation |
shake | Enable shake effect |
mobile | Enable typing effect on mobile |
Background Effects
Beautiful ribbon background, can be set to change ribbon on each refresh or on each click
1 | canvas_ribbon: |
Parameter | Description |
---|---|
enable | Enable ribbon effect |
size | Size of the ribbon |
alpha | Opacity of the ribbon |
zIndex | z-index of the ribbon |
click_to_change | Change ribbon on click |
mobile | Show ribbon on mobile |
For more configuration, refer to canvas_ribbon
Beautiful ribbon background that floats
1 | canvas_fluttering_ribbon: |
1 | canvas_nest: |
Parameter | Description |
---|---|
enable | Enable nest effect |
color | Color of the lines |
opacity | Opacity of the lines |
zIndex | z-index of the lines |
count | Number of lines |
mobile | Show effect on mobile |
Mouse Click Effects
1 | fireworks: |
Parameter | Description |
---|---|
enable | Enable fireworks effect |
zIndex | z-index of fireworks (-1 means behind / 9999 means in front) |
mobile | Show fireworks on mobile |
1 | # Click to show hearts |
1 | # Click to show text, text can be customized |
Parameter | Description |
---|---|
enable | Enable text effect |
text | Text content |
fontSize | Font size |
random | Randomize text display |
mobile | Show text on mobile |
Lightbox
If you do not want to add lightbox for a specific image, use HTML format to reference the image and add no-lightbox
class name to the image
1 | # Choose: fancybox / medium_zoom |
You can configure fancybox
or medium_zoom
to enable lightbox.
Leave it empty if no lightbox is needed.
FancyBox
Medium Zoom
Tag Plugins
For details, see Tag Plugins
Mermaid
The theme supports Mermaid.js, which can be used to draw flowcharts, sequence diagrams, etc., in articles.
1 | # Mermaid |
Writing Methods
The theme supports two writing methods
Tag Plugin
You can use the tag plugin method to use Mermaid.js For details, see Tag Plugins
Code Block Writing
You can use the code block method to use Mermaid.js
Hexo version needs to be 7.0 or above
Add
exclude_languages: ['mermaid']
to the Hexo configuration file1
2
3
4
5
6
7
8
9
10
11
12
13syntax_highlighter: 'highlight.js'
highlight:
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
exclude_languages: ['mermaid']
prismjs:
preprocess: true
line_number: true
tab_replace: ''
exclude_languages: ['mermaid']Set
code_write
totrue
in the Mermaid configuration of the Butterfly theme
Demo
1 | graph TD; |
Pjax
When a user clicks a link, the parts of the page that need to be updated are done so via Ajax, and then the browser's URL is modified using HTML5's pushState.
This avoids reloading identical resources (css/js), thereby improving page load speed.
1 | pjax: |
For some third-party plugins, Pjax may not be supported.
You can add web pages to the exclude
list to exempt them from Pjax.
Clicking these pages will reload the website.
After using Pjax, some custom JavaScript may become ineffective and need to be re-invoked when navigating pages. Refer to the Pjax documentation.
Also, some specific pages' js/css will be loaded on all pages after using Pjax.
Snackbar - Toast Notification
Enable the Snackbar based on personal preference.
1 | # Snackbar - Toast Notification |
Snackbar not enabled
Snackbar enabled
Instantpage
When the mouse hovers over a link for more than 65 milliseconds, Instantpage preloads the link, improving access speed.
1 | # https://instant.page/ |
Pangu
If you're like me and feel uneasy every time you see Chinese characters and English letters, numbers, and symbols crammed together on a webpage, you'll want to insert spaces between them. This plugin is exactly what you need to navigate the web more comfortably, as it automatically inserts spaces between all Chinese characters and half-width English letters, numbers, and symbols on the webpage.
1 | # https://github.com/vinta/pangu.js |
field
supports only two parameters: post
(effective only on post pages) and site
(effective site-wide).
PWA
To add PWA features to Butterfly
, you need to follow these steps:
Open the hexo working directory.
Run
npm install hexo-offline --save
oryarn add hexo-offline
.Create a file named
hexo-offline.config.cjs
in the hexo directory and add the following content:
1 | // offline config passed to workbox-build. |
For more details, refer to the official hexo-offline documentation.
- Enable the PWA option in the
theme configuration file
.
1 | pwa: |
- Create a
manifest.json
file in thesource/
directory.
1 | { |
You can also quickly create a manifest.json
using the Web App Manifest. (Web App Manifest requires at least one 512x512 pixel icon).
Use the
Chrome
Lighthouse
plugin to check if the PWA configuration is effective and correct.- Open the blog page.
- Launch the
Lighthouse
plugin (Lighthouse plugin requires at least one 512x512 pixel icon).
For more information on PWA (Progressive Web Apps), refer to Google Tools for Web Developers.
Open Graph
Add some meta data such as thumbnails, titles, and dates in the head
. When you share a webpage on certain platforms, the platform will read the Open Graph content and display information like thumbnails and titles.
1 | # Open graph meta tags |
CSS Prefixes
Some CSS properties are not supported by all browsers and need corresponding prefixes to be effective.
Enabling css_prefix
will automatically add prefixes to some CSS properties (increasing the size by 20%).
1 | # Add the vendor prefixes to ensure compatibility |
Inject
Supported from version 2.3.0 and above
If you want to add extra JavaScript, CSS, meta tags, etc., you can add them in inject
. This supports adding to the head (before the </body>
tag) and the bottom (before the </html>
tag).
Note: Add the content in standard HTML format.
For example:
1 | inject: |
Note: If your site root directory is not '/', you need to include your root directory when using local images.
For example: If your site is https://yoursite.com/blog
and you want to reference css/xx.css
, set it as <link rel="stylesheet" href="/blog/css/xx.css">
.
CDN
The last part of the configuration file is CDN, which includes files referenced by the theme. You can configure the CDN yourself (please do not modify unless necessary, and confirm that the links are accessible after configuration).
1 | # CDN Settings |
Parameter | Explanation |
---|---|
internal_provider | Internal files of the theme Options: local/jsdelivr/unpkg/cdnjs/custom local for local loading, custom for custom format, needs to configure custom_format Note: If using the Dev version, it can only be set to local |
third_party_provider | Third-party files Options: local/jsdelivr/unpkg/cdnjs/custom local for local loading, custom for custom format, needs to configure custom_format Note: If you choose local, you need to install the hexo-butterfly-extjs plugin |
version | true/false to add the specified version number to the CDN |
custom_format | Custom format |
option | You can replace some files here, which will override the original configuration |
version
To modify the version number, you can change the version in the 'plugins.yml' file in the theme directory
.
Please ensure that the version number you modify is included in the CDN you use.
custom_format
Provides the following parameters:
Parameter | Explanation |
---|---|
name | Package name on npm |
file | File path on npm |
min_file | Minified file path on npm |
cdnjs_name | Package name on cdnjs |
cdnjs_file | File path on cdnjs |
min_cdnjs_file | Minified file path on cdnjs |
version | Plugin version number |
Partial list of available third-party CDNs:
Please ensure that the CDN you choose includes the third-party plugins used by the theme.
Provider | Format | Remarks |
---|---|---|
Staticfile (Qiniu Cloud) | https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file} | Sync with cdnjs |
BootCDN | https://cdn.bootcdn.net/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file} | Sync with cdnjs |
Baomitu (360) | Latest version: https://lib.baomitu.com/${cdnjs_name}/latest/${min_cdnjs_file} Specified version: https://lib.baomitu.com/${cdnjs_name}/${version}/${min_cdnjs_file} | Sync with cdnjs |
Elemecdn | Latest version: https://npm.elemecdn.com/${name}@latest/${file} Specified version: https://npm.elemecdn.com/${name}@${version}/${file} | Sync with npm |