Hugo English Content Appears on Chinese Pages

After setting up my English blog, I accidentally noticed English content tags appearing on the tag pages during an update yesterday. Initially, I thought there was an issue with the logic of generating the tag pages. The variable used for generation was $.Site.Taxonomies.tags, which seemed to have no issues. I thought about various filtering methods, but none seemed to solve the problem.

Then, after writing a new blog post last night, I noticed that English article content started appearing in the similar recommendations. Upon clicking into it, I realized something was off: although the article content was in English, the blog site name and the copyright information below were all in Chinese. Then I took another look at the path and found it didn't match my expected path for English content. The path of this article was /en/posts/2024/nuxt-cannot-init/, but I expected it to be /en/2024/nuxt-cannot-init/.

From this, it seems that the crux of the problem is that English content files are being treated as part of the Chinese blog and processed as such. Therefore, English content appears when generating tag pages and retrieving related pages. The reason for this issue is that my directory settings for the two languages are not quite appropriate. The Chinese content directory includes the English directory, causing English content to be treated as part of the Chinese content.

1
2
3
4
5
6
7
[languages]
    [languages.zh]
        contentDir = 'content'
        ...
    [languages.en]
        contentDir = 'content/en'
        ...

So, I changed the path of the English content to contentDir = 'content_en', created a directory with the same name, and moved the English content files to this new directory. Problem solved!