Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Custom slug for tags #254

Open
cuixiping opened this issue May 13, 2024 · 3 comments
Open

Feature Request: Custom slug for tags #254

cuixiping opened this issue May 13, 2024 · 3 comments

Comments

@cuixiping
Copy link

cuixiping commented May 13, 2024

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/.

@xenocrat
Copy link
Owner

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.

@cuixiping
Copy link
Author

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
image

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.

@xenocrat
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants