Introduction
This blog will introduce how to use Github and Hexo to build a personal blog. Specifically, I will first submit the basic steps to create a blog and then present how to optimize the blog.
1. Build the Blog
For the basic steps, please refer to: Use Hexo + Github Pages to build a free exclusive blog (ConnorLin, 2016) and Hexo and NexT offical documentation (Zhu, 2021).
2. Optimize the Blog
To optimize the blog, please refer to: Optimization of personal blog based on Hexo and NexT (Chou, 2019) and Hexo Theme NexT (version5.1.4) official documentation (IIssNan, n.d.).
Note: It is recommended to install NexT V5.1.4 first because this version has many related documents for reference. The new version of NexT lacks relevant documents, so it is not easy to solve bugs once you encounter them.
3. FAQ
3.1. How to center the footer?
Open themes\next\source\css\_schemes\Mist\index.styl
, change the text-align
in .footer-inner
to center
:
1 | .footer-inner { |
3.2. How to center the post title, post metadata, post tags, and the read more button?
Open \themes\next\source\css\_custom\custom.styl
, add the following codes into it:
1 | // read more center |
3.3. How to modify the Read More
button style?
Open \themes\next\source\css\_custom\custom.styl
, add the following codes into it:
1 | // read more style |
3.4. How to fix the error generated by clicking the menus like tags?
When clicking menus, you may get an error:Cannot GET /about/%20
. To slove it, you can open \themes\next\_config.yml
, find menu settings, and delete the space between /
and ||
:
Code before modification:
1 | menu: |
Code after modification:
1 | menu: |
3.5. How to fix the error generated by clicking the menus categories?
When clicking the menu categories
, you may get an error:Cannot GET /archives/%7C%7C%20list/
. To slove it, you can open \themes\next\layout\_macro\sidebar.swig
, then, use Ctrl + F
command, to search the codes:
1 | <a href="{{ url_for(theme.menu.archives).split('||')[0] | trim }}"> |
and replace them with:
1 | <a href="{{url_for(theme.menu.archives.split('||')[0])| trim}}"> |
3.6. How to fix the error generated by changing the theme to next
?
You may encounter an error when changing the theme to next
in the site _config.yml
. This is because Hexo deleted swig
after version 5.0. We need to install it manually. Install swig by executing the following command in the root directory of the site:
1 | nmp i hexo-renderer-swig |
3.7. How to fix the error generated by clicking the menus categories?
When clicking the menu categories
, you may get an error:Cannot GET /archives/%7C%7C%20list/
. To slove it, you can open \themes\next\layout\_macro\sidebar.swig
, then, use Ctrl + F
command, to search the codes:
1 | <a href="{{ url_for(theme.menu.archives).split('||')[0] | trim }}"> |
and replace them with:
1 | <a href="{{url_for(theme.menu.archives.split('||')[0])| trim}}"> |
3.8. How to change the color of the footer heart?
Open \themes\next\source\css\_common\components\footer\footer.styl
, add color: #ff0000;
into it .with-love{}
:
1 | .with-love { |
3.9. How to change the style of the count values at the bottom?
There are three files needing to modify. First, open \themes\next\_config.yml
, find the busuanzi_count
, and modify the codes as follows:
1 | busuanzi_count: |
Second, open \themes\next\layout\_third-party\analytics\busuanzi-counter.swig
, and modify the codes as follows:
1 | {% if theme.busuanzi_count.enable %} |
Finally, open\themes\next\source\css\_common\components\third-party\busuanzi-counter.styl
, and modify the codes as follows:
1 | if hexo-config("scheme") == Pisces |
3.10. How to solve the problem that the page-turning labels are not displayed properly?
Open \themes\next\layout\_partials\pagination.swig
, and modify the codes as follows:
1 | {% if page.prev or page.next %} |
References
1.ConnorLin. (2016). Use Hexo + Github Pages to build a free exclusive blog.
2.Chou, B. (2019). Optimization of personal blog based on Hexo and NexT.
3.Zhu, J. (2021). Hexo and NexT offical documentation.
4.IIssNan. (n.d.). Hexo Theme NexT (v5.1.4) Github repository .
5.IIssNan. (n.d.). Hexo Theme NexT (v5.1.4) official documentation .
6.RUNOOB.COM. (n.d.). Markdown tutorial.
7.Leafney. (2019). Add gitalk comment system to Hexo blog.
8.Leafney. (2019). Add gitment comment system to Hexo blog.
9.Leafney. (2021). Encrypt Hexo blog posts.
10.Xia,Z.Y. (n.d.). Encryption plugin Github repository: hexo-blog-encrypt.
11.Fish_404. (2018). Move NexT Mist theme sidebar to the left.
12.Garry. (2019). Hexo avatar settings.
13.Sun. (2018). Use Hexo+NexT to create a cool blog.
14.XieJaca. (2020). Solving the problem that the page-turning labels are not displayed properly.