Miscellaneous Notes
Miscellaneous notes during the use of this blog.
This is a personal notes that keeps track of all procedure, problems, tricks, etc. during the building and writing process of this blog. Hopes it will help someone, at least me, when I’d like to migrate to another blog or unfortunately I have to re-build my blog.
Building Notes
Installing hexo is quite simple: just install it through npm
.
At 2022-09-06, the newest version of hexo is fully compatible with my workaround:
- Windows 11 + WSL 2
- Ubuntu 20.04 LTS
- Node.js v18.x
To install Node.js
on Ubuntu, follow the official guide of installing Node.js
binary distribution, where the commands are already included below.
1 | curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - |
Initialize a Blog Repository
Following the hexo official guide, run
1 | hexo init <folder> |
Personally, I put my blog folder just in ~/fallcicada.github.io/
, which is put in github repo fallcicada.github.io
.
Customization in Blog
As often mentioned in Chinese SNS, the end of customization is the default. I do not want to put much focus on the customization part of the blog. Except for a clean hexo theme Icarus, I made a few changes to my blog, mainly about the format of blogs.
Hexo Theme Icarus
To install hexo theme Icarus, follow its Readme or its guide. Some possible dependencies should also be installed together.
1 | npm install -S hexo-theme-icarus hexo-renderer-inferno |
This will automatically modify your _config.yml
, and will also create another theme-specific configuration file _config.icarus.yml
at the same directory.
Unlisted configuration is kept the same as default.
To order the posts by newest-updated, rather than newest-posted, I changed index_generator.order_by
to -updated
.
In addition, the highlight
config should be carefully checked, as I have met several bugs due to inappropriate settings under this part.
To ensure that 2 enters break a line rather than 1 enter, set marked.gfm: true
in the config file, as in 回车就是换行和预览不一致异常问题.
1 | # Basic Information |
As for Icarus-specific config, I removed a lot of unnecessary component, as noted below.
Additionally, the logo, or any other image that needs to be placed in the website template, should be put in directory <icarus directory>/source/img/xxx
, and be indexed as /img/xxx
in config file.
The directory of Icarus, installed directly through npm
, should be <blog directory>/node_modules/hexo-theme-icarus
.
But there exists some bugs when the blog is deployed with Github Action.
As a result, I manually moved Icarus from <blog directory>/node_modules/hexo-theme-icarus
to <blog directory>/themes/icarus
, which resolves most of the issues.
1 | # Modified config |
Page Layout
To modify the page layout, follow the layout guide of Icarus theme.
Personally, I modified the <icarus_directory>/layout/layout.jsx
and <icarus_directory>/common/widgets.jsx
to have a narrower widget column and wider content column.
1 | <div class={classname({ |
1 | function getColumnSizeClass(columnCount) { |
As Icarus uses the 12 columns system of bulma, the total width of the same type needs sum up to 12. For example, the modification above makes the width of widget column and content column in double-column desktop mode from 4:8 to 3:9.
Fonts
The style sheets for Icarus theme are available at themes/icarus/include/style/
.
To change the font, modify the $family-sans-serif
and $family-code
in base.styl
.
To change the font size of the articles, refer to article.styl
and codeblock.styl
.
I have only made a few changes to the font size, which are listed below:
1 | - $article-font-size ?= 1.1rem |
1 | figcaption |
Custom Sticker Helper Functions
(Note: the following 2 lines are deliberately left here.)
Test.
It works!
To start with, the code for these emojis are just {% emoji EMOJI_NAME %}
.
To modify the theme (or, in other words, hexo) so that one can use hexo tags to add emojis conveniently to blog, you need to create an extra javascript file to register new tags to hexo.
Although not mentioned in the doc of API of Tag, according to API of Helper, it is suggested that such javascript files should be placed at scripts/
or themes/<theme_name>/scripts/
.
I created a new file, themes/icarus/scripts/emoji.js
, and write the following content to it:
1 | const logger = require('hexo-log')(); |
It is necessary to use class="not-gallery-item"
for such emojis to prevent them being recognized as normal images.
And I also need to import this file in themes/icarus/scripts/index.js
by adding the following lines at the end of the original file.
1 | /** |
Now, the custom tag on emoji will be registered for hexo!
When you try to add an emoji in your blog, put them in sources/emoji/xxx.png
, and insert it in your blog with {% emoji xxx.png %}
.
If the image is in png
format, you can leave the .png
part and simply use {% emoji xxx %}
.
This is really convenient, especially for those BBS users who are addicted to adding emojis in their posts, isn’t it?
Writing Blog
I am simply using VSCode + Markdown to write my blog. That’s the easiest but most effecient way for me.
Deploying Blog
I used Github Action to deploy my blog automatically after pushed to the main branch of my Github repo.
The raw contents of my blog is pushed to the main
branch of the repo, except the public/
folder not uploaded.
An additional file .github/workflows/pages.yml
is needed which describes what to do under what situation for Github Action.
I used an almost the same file as this provided by hexo, except for the version of Node.js
.
The above content is completely sufficient for automatic deploy of hexo blog. For more detailed introduction of how Github Action works, refer to here.
TODO
- Keep a note of my first CD ripping experience.
- Upload most of my undergraduate course materials to Github.
- Planning to add some stickers to my blog. It is worth to try to find a way like pattern matching and replacing to save the time of manually adding stickers in in-line form in my blog.
- Move my personal note from local onto the blog might be a good choice.
- Keep a diary, or weekly diary? Something like that might not be a bad choice.
- No other plans? I think the above plans are enough for a short-term workload, lol.
Miscellaneous Notes