fuwari icon indicating copy to clipboard operation
fuwari copied to clipboard

Suggestion: Set Language for specific Posts

Open at-wr opened this issue 1 year ago • 2 comments

Currently, the project only supports a single global language setting. However, I would like to propose a solution for users like myself who wish to publish posts in multiple languages, specifically Chinese and English.

I suggest adding a "language" field as optional frontmatter for each post. Users could then specify the language of their posts using tags such as "en" for English, "zh" for Chinese (also "zh_TW", "zh_HK", etc.), and "jp" for Japanese.

Also, thanks for the amazing project :3

at-wr avatar Aug 11 '24 07:08 at-wr

Thanks for your suggestion, but I’m a bit unclear on what the language field should actually do. Could you please explain further?

saicaca avatar Aug 11 '24 15:08 saicaca

By default, the starting tag of <html> contains lang which defines the global language of the entire webpage. According to my test, this was reflected by the value lang set in SiteConfig (/src/config.ts).

In my expectation, the example frontmatter of a post should be like this:

---
title: Hello World
description: Here goes the description
published: 2024-08-12
draft: false
category: Casual
tags: []
language: en
---

Where the language field defines the language of the post, and overwrites the value in <html lang="">.

For bloggers who have the need to write articles in multiple languages, being able to set language for a single post offers a better advantage for search engine crawling, which is also a type of SEO.

at-wr avatar Aug 12 '24 01:08 at-wr

Closed as #151 has been merged.

at-wr avatar Aug 27 '24 16:08 at-wr