What's the Best URL Structure: Slugs and IDs?
Asked by
CuriousCat42
I'm trying to decide between two URL structures for my articles. The first option is /news/12345-slug-here-blah-blah/2 and the second is /news/12345/slug-here-blah-blah/2. I definitely need to keep the reference number (12345) at the beginning to avoid issues with truncated URLs, and the page number (like /2 or /3) should be at the end. My main concern is how to separate the reference number from the slug contentโshould I use a dash or a slash? I'm considering user experience when sharing links and want to ensure it's also optimized for SEO. What's the best practice for 2025?
Answers
It really depends on what the reference number signifies. If it's just an id for the article, then using /news/{id}/{slug}?page=1 might be more organized. But if you need older versions, consider a canonical URL that could help in browsing past versions.
Reply to this answer
The first option makes sense as the slug is mainly for human readability. Ideally, the URL should be functional even without the slug, so that both /news/12345-slug-here-blah-blah/2 and /news/12345/2 should work just fine. Just remember to set a canonical URL in your headers to avoid duplicate content issues. I also think using /news/12345-slug-here-blah-blah/page/2 makes it clearer that youโre on a different page.
Reply to this answer
I personally prefer the first format. The second option suggests that there could be more articles under '12345', which might not be the case. The first one feels cleaner and more straightforward for users sharing links.
Reply to this answer
If the reference number is essential, Iโd say go with the second format. It allows you to change the slug without affecting the URL. This way, you can keep links intact even if you update your article titles.
Reply to this answer
Honestly, I think this decision is about user preference. The first one has better SEO implications since it avoids unnecessary directories, but some argue for semantic clarity in the second option. Maybe simplifying it further by dropping 'news' could make the URLs cleaner too.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions