Open xiyuvi opened 6 months ago
My guess is that you’re using slugify
on the permalink for the tag’s individual page, which drops the Chinese characters (sindresorhus/slugify#63), and what’s left is just /tags/
. I’m not sure what the solution is here, because the tag name doesn’t have anything in it that slugify
knows how to handle. What would you ideally like its URL to look like?
I used Chinese TGA in the article.
The URL I expect is like this https://xiyu.pro/tags/%E6%94%BB%E5%87%BB/
It is displayed in Chinese in my address bar. If your system does not have a Chinese font library, it may be displayed as the default content https://xiyu.pro/tags/攻击/
Thank you for your reply. God bless you
My guess is that you’re using
slugify
on the permalink for the tag’s individual page, which drops the Chinese characters (sindresorhus/slugify#63), and what’s left is just/tags/
. I’m not sure what the solution is here, because the tag name doesn’t have anything in it thatslugify
knows how to handle. What would you ideally like its URL to look like?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeuricomponent I have solved this problem, and the URL does not need to be formatted at all because the URL already supports Chinese, Japanese, Thai, spaces, and so on. It is an element based log that uses slugify to beautify the URL. However, slugify does not support Chinese, which leads to this problem.
I deleted slugify and successfully resolved this issue. original
permalink: /tags/{{ tag | encode }}/
now
permalink: /tags/{{ tag }}/
And the official example's tga "second tag" containing spaces did not report an error, and the URL changed to http://localhost:8080/tags/second%20tag/
I personally think that slugify should not be used by default, as this way the webpage can be displayed normally
I’m glad you found a solution! I don’t think Eleventy uses slugify
on its own. There’s in fact a warning on the appropriate docs page:
slugify
currently ignores characters for Japanese, Chinese, and others. If you need to slugify these characters, add your own universal filter with an alternative library likelimax
ortransliteration
. (More context at Issue #2537)
In case you still want to create friendlier versions of your URLs, you could look at those libraries. The aforementioned 11ty/eleventy#2537 seems to have concluded with the same approach you’ve switched to, though.
md
Error content