-
Notifications
You must be signed in to change notification settings - Fork 6
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
Alias support #5
Comments
Currently, only the following two approaches are available:
Does that help? Do you feel we need something else? Perhaps a separate |
I would to understand what is the best approach to developing this case. id: 9, alias: my-first-post The normal get request should be www.domain.com/post/:id/reader what should be the result www.domain.com/post/my-first-post and generate a sitemap.xml file. I should directly to create a route using the alias instead of id www.domain.com/post/:alias ? It's correct the approach or there is a better way ? Thanks. |
It’s common practice to include both the ID and the alias:
Of course, it’s up to you whether you want to check the correctness of the alias. Usually, wrong aliases are accepted but redirected to the correct one. What do you need the routing component to do? |
Yes id and aliar is the correct way.
where my-first-post is the alias. In sitemap I have to generate link with alias so I need that if in the browser is type
show me the correct one. Thanks. |
So you also want to identify posts only based on their alias, without any ID at all? Do you even need the ID then? And what do you want to do? Redirect from one to the other? Which direction? Or do you want to support both routes and handle them in the same way? |
This is my first test to build a frontend project with your framework so I know what should be the result but I don't know the way for this I am asking. Most of the CMS system instead to show sitemap with details/id they show the alias for be SEO friendly. I suppose that is an url rewrite or... I don't know what is the best way for don't compromise the indexing. In the other from the management point of view it is certainly better to use the ids instead of the aliases that even with all the controls there could be some inconsistencies. So for this my question... what is the good practise for manage the route for has url seo friendly ? Thanks. |
Well, let’s discuss the most common practice using a popular example:
As you can see, the form is:
This approach is easy to manage and also good from a SEO perspective, so it’s a best practice to do it like this. You don’t need multiple versions or endpoints for this. Just always include both the ID and the display name. As for generating the display names, there are libraries for this: |
Thanks Great!
for sitemap I'll generate an XML with a SELECT and I'll add it in cron job or I'll think some other solution. Thank you very much you leave me a doubt if was penalized that solution or not. :) |
You will quickly find that there are tons of “edge cases”, or really any not-just-ASCII words, where the libraries will provide better results than your simple solution, which is fine otherwise. As for the sitemap, you can either generate it on the fly just when it’s requested, or pre-generate it and store the result somewhere. |
Yes I just considered normal case but checking your link I saw that is better and complete. ( I don't know if is your preference or a case that you put this library at first position, tomorrow I'll check better but I like the approach of the first one. (https://github.com/ausi/slug-generator) For sitemap I was thinking to generate a file I don't know if update by cron job or just when change the page structure. Already I added extra field for include and exclude page or allowed or not bot. Thanks again for your time and rapid support. |
Hi,
there is any methosor way for manage routes with alias ?
for example convert
www.domain.com/post/:id/reader
to
www.domain.com/post/:alias
Thanks.
The text was updated successfully, but these errors were encountered: