Open cuixiping opened 5 months ago
Hello there,
Custom slugs for tags are difficult to implement, because the original design of the tags module is decentralized: tags are generated and saved as attributes of each post instead of being saved in a centralized database table. This means the slug must be created deterministically from the tag text.
I'll have a think about this and report back if I think of a good solution.
I suggest:
If there is a custom slug list, then use the custom slug which match the tag text.
Use url encoded string if no match found, for example 文字
becomes %E6%96%87%E5%AD%97
, like wikipedia style.
https://zh.wikipedia.org/wiki/%E6%96%87%E5%AD%97
When user write a post, user can write any tag text freely or select from the tag text list. User can configure custom slug later in tag manager page.
With the latest release, I'm enforcing strict rules for all slugs - but I'm aware this might be an unwelcome change for non-English speaking users, so I've created a global constant to relax all slugs for posts, pages, categories, and tags. This will result in something like your suggestion above: URL encoded slugs.
You can relax the slug rules globally by setting the constant SLUG_STRICT
to false
in common.php. I didn't create a configuration option in the admin console because changing this constant will cause existing tags to misbehave. If you disable strict slugs, you'll need to do Admin > Manage > Tags > Edit > Rename for each of your existing tags. This will update the tag values in the database using the more relaxed slug rules.
Currently, the tag page url will look like
/tag/86e921607657572b438d5c03156008dc/
when tag text is Asian characters, for example文字
.If user can config custom slug when add or edit tags, the url will be very nice like
/tag/custom-slug/
.