Back
Featured image of post Must Read Content for Blogging

Must Read Content for Blogging

Things you need to pay attention to when writing a blog with Hugo.

Introduction (updated on 2024.11.14)

Recently, I want to pick up the habit of blogging again, but I found that the previous Hexo blog | (Github-Pages) was a bit fancy. After searching for a long time, I found that this Hugo | (Github)’s Stack theme | (Github) is quite in line with my aesthetics, so I decided to use Hugo to write a blog.

There are a few points to note:

  • The version I use is Hugo-stack theme-magic modification version | (Github).
  • Since this version (as of now) has not been updated for two years (the last update was in 2022), for the latest version of Hugo, executing hugo server may report an error. You need to copy the error cause yourself and ask AI (such as ChatGPT, etc.) to solve the error.

Usage (MarkDown syntax)

Collapsible code block

This is the title (Click to expand and collapse)
1
2
3
4
5
6
7
// Remove the \ in front of %
{{\% spoiler %}}

Content

{{\% /spoiler "This is the title" %}}
// Remove the \ in front of %

Common sense (for me, I need to remember this)

HTML character set - space

  • Space:   Press the space key to display it. The width is affected by the font.
  • Space:   has a width of $\frac{1}{2}$ Chinese characters, not affected by fonts.
  • Space:   has a width of 1 Chinese character, not affected by fonts.

Unresolved issues (updated at any time)

  • The following issues are based on hugo v0.138.0 (maybe I don’t know how to operate/doge).
How to check hugo version? (Click to expand and collapse)

Enter hugo version in cmd

1
Output: hugo v0.138.0-ad82998d54b3f9f8c2741b67356813b55b3134b9+extended+withdeploy windows/amd64 BuildDate=2024-11-06T11:22:34Z VendorInfo=gohugoio

Multi-language adaptation of categories

I tried to use _index.md and _index.en.md in the test file in the ./content/categories directory, but the result was not what I expected. In the homepage category, it can only be displayed as test or test, and there is no multi-language adaptation.

The right column of the icon is not suitable for multiple languages
The right column of the icon is not suitable for multiple languages

Initial directory structure (Click to expand and collapse)
1
2
3
4
5
6
7
8
├─content
│ ├─categories
│ │ _index.en.md
│ │ _index.md
│ │
│ └─test
│ │ _index.md
│ └─ _index.en.md

In the end, only the test and test directories can be configured separately:

Final directory structure (Click to expand and collapse)
1
2
3
4
5
6
7
8
├─content
│ ├─categories
│ │ │ _index.en.md
│ │ │ _index.md
│ │ │
│ └─test
│ │ _index.md
│ └─ _index.en.md

In the end, only the test and test directories can be configured separately:

Final directory structure (Click to expand and collapse)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
├─content
│ ├─categories
│ │ │ _index.en.md
│ │ │ _index.md
│ │ │
│ │ ├─test
│ │ │ _index.en.md
│ │ │
│ │ └─test
│ │ _index.md

As shown in the figure:

Directory structure
Directory structure

Appendix

This article was originally published in CaiHongTu Blog and follows the CC BY-NC-SA 4.0 agreement. Please keep the original source when copying.


END

Licensed under CC BY-NC-SA 4.0
Last updated on Feb 12, 2025 21:23 CST
Built with Hugo
Theme Stack designed by Jimmy
© Licensed Under CC BY-NC-SA 4.0