Setting up This Blog
It is not technically difficult to set up this blog. But testing different configurations costs a lot of time.
Here are some details of how I set up this blog using Hexo with theme Redefine.
Things I need
There are four major things that I need for writing posts:
- code blocks
- math notations
- music notations
- encryption
- maybe multilingual support
Code blocks
Supported out of the box, and should be supported by every markdown renderer.
Examples:
- Inline code are fenced with the tick
`symbol:`code`give youcode. - Code blocks can be fenced in arbitrary lines with
```, where you can also specify the language to get syntax highlighting like this:
1 | ```c |
gives you:
1 |
|
Math Notations
Math notations are not directly rendered with markdown so a plugin has to be added.
I chose to use MathJax for this functionality with the following config:
1 | mathjax: |
Inline math can be wraped with $ sign:
$\sum_{i=0}^{n}\frac{1}{n}$:
Large equations can be wraped with $$ in arbitrary lines:
1 | $$ |
Example matrix multiplication:
Music Notations
Writing music notations is however not standardized in markdown language.
ABC notation is a nice way to write notes like code, and the node module abcjs provides rendering with ABC notation.
There is also a plugin called hexo-tag-abcjs. However, this plugin is outdated and is not easy to use.
Now create a tag called abcjs and then write a script to let hexo render it!
Note
The ABC music notation is not bracket-friendly, which means it might create confusion in the markdown syntax (not happened yet but possible).
Example:
1 | {% abcjs %} |
But we still need a script to render this. Create a scripts folder inside your hexo root folder, and add a script hexo-abcjs.js. Then we need to process tags and transform the ABC notation into html.
1 | // Process tag: {% abcjs %} ... {% endabcjs %} |
This script also allows us to add abcjs render options if needed.
Note
Using the wrap rendering option might cause issue! Avoid if possible!
Related issue: https://github.com/paulrosen/abcjs/issues/1125
Note
If you are using swup, scripts inside html will not be automatically executed. You have to manually reload the page to make it work.
Soluton: load <script src="/js/abcjs-basic.js"></script> outside the swup container. If you are using theme Redefine, just edit the config:
1 | inject: |
You also have to edit one of the source file of Redefine located in themes/redefine/layout/components/swup.ejs and modify optin: false of the SwupScriptsPlugin:
1 | new SwupScriptsPlugin({ |
Now the script will be automatically executed without reloading the page.
Result:
Encryption
Not all posts should be available to the public, you only want friends etc. to see it.
A nice plugin called hexo-blog-encrypt can do it.
My theme Redefine already contains it with some modifications so I can use it out of the box.
Just put a password field inside the front matter of the post you want to encrypt like this:
1 | title: Encryption is the Key |
Warning
All the decryption logic is stored in the frontend, so offline bruteforce is possible. You should use a strong password.
Multilingual
It is not really worth it to write one thing in every possible language. But in some cases, it might be useful to have a section writte in different languages, e.g. if you are learning a new language.
The tabs functionality is really nice to use.
Example (machine-translated):
The closer you look, the less you see
看得越近,看到的反而越少
Je genauer du hinschaust, desto weniger nimmst du wahr.
자세히 들여다볼수록 보이는 것이 줄어든다.
よく見ようとするほど、逆に見えるものが少なくなる。
- Title: Setting up This Blog
- Author: cryfrogg
- Created at : 2025-11-23 03:23:23
- Updated at : 2025-12-16 02:44:13
- Link: https://cryfrogg.github.io/uncategorized/Setting-up-This-Blog/
- License: This work is licensed under CC BY-NC-SA 4.0.