In the Butterfly document - Theme Configuration Part 1, the process of using custom code highlighting themes has been explained.
This article serves as a practical tutorial on using custom code coloring.
Highlight
We'll take the example of using the Kimbie dark
theme for code coloring.
Configure hljs
to true
Modify the _config.yml
file in the root directory of your Hexo project.
1 | highlight: |
Configure highlight_theme
to false
Edit the theme configuration file.
1 | highlight_theme: false |
Download and Modify the CSS File
Go to Github and find the Kimbie dark
CSS.
Create a folder named self
in the source
folder of your Hexo project. Inside the self
folder, create a file named Kimbiedark.css
.
Copy the CSS code of Kimbie dark
from Github and paste it into Kimbiedark.css
. (Alternatively, you can directly download this CSS file from Github)
The content of Kimbiedark.css is as follows:
1 | /* |
Modify the css to
1 | /* |
File Inclusion
Modify the theme configuration file
1 | inject: |
Run Hexo
After running Hexo, you should be able to see the modified effect.
Prismjs
Using the prism-duotone-light
theme for color scheme customization.
Configure highlight_theme
to false
Modify the theme configuration file
1 | highlight_theme: false |
Download and Modify CSS File
Find the CSS file for prism-duotone-light
on Github
Create a self
folder in the source
directory of Hexo and then create a duotone.css
file inside the self
folder.
Copy the CSS code for prism-duotone-light
from Github to the duotone.css
file. (You can also directly download this CSS from Github)
prism-duotone-light code is as follows:
1 | /* |
Modify the css to
1 | /* Newly Added Content |
Import Files
Modify the theme configuration file
1 | inject: |
Run Hexo
After running Hexo, you should be able to see the modified effect.