Fixing Up Japanese Language Tags
Two years ago, I took a trip to Japan with Tess. I wrote up my experiences on that trip in various posts, and shared several photos.
Feeling perhaps overly-confident in my ability to read Japanese and my website engine’s ability to handle non-ASCII content, I tagged many of those pages with Japanese language tags: 日本, 日本語, 東京, 京都.
This led to some unweildy URLs because of how Hugo rendered the Japanese language tags names into ASCII when generating file paths.
<ul>
<li><a href="/tags/nature/">Nature</a></li>
<li><a href="/tags/temples/">Temples</a></li>
<li><a href="/tags/%E6%97%A5%E6%9C%AC/">日本</a></li>
</ul>
It’s not necessary to convert URLs to punycode if your document is UTF8, but Hugo does it. Browsers should automatically handle converting to and from punycode when sending HTTP requests over the wire. Nevertheless…
I went through my post tags and updated all of the Japanese language tags to have English slugs and Japanese titles. Now, these URLs are more friendly for typing (and the file paths are easier to navigate in a terminal) while still showing up in posts and tag list pages with the Japanese name.
<ul>
<li><a href="/tags/meta/">Meta</a></li>
<li><a href="/tags/hugo/">Hugo</a></li>
<li><a href="/tags/japanese/">日本語</a></li>
</ul>
#One More Thing
I often tag posts with tags by location. For example, several of my posts from
my Japan trip in 2023 are tagged with /tags/japan
and with (e.g.)
/tags/tokyo
. For the place tags that are within a large region, like cities
within countries, I added the larger region to the tag:
/tags/tokyo
→/tags/japan-tokyo
/tags/kyoto
→/tags/japan-kyoto
I only did this for the Japan tags for now. I’ll be making more such updates going forward.