Ask HN: URL format for blog posts - which format is best?
Example 1:
myblog.com/my-readable-but-long-blog-post-title-in the-url
OR
myblog.com/posts/my-readable-but-long-blog-post-title-in the-url
Example 2:
myblog.com/2022/08/my-readable-but-long-blog-post-title-in the-url
Example 3:
myblog.com/62642060
---
Pro and cons:
Examples 1 and 2: Readable but long URLs. They may also help SEO (search engine optimisation).
Example 2: The date in the URL provide helpful context.
Example 3: A short URL easily shared (but URL is not descriptive).
Which of these URL formats do you prefer? Or do you think they don't really matter?
Thank you :-)
9 comments
[ 2.0 ms ] story [ 31.9 ms ] thread> https://en.cppreference.com/w/cpp/container/vector
See? You don't even need to open it to know what's going to be there.
Sadly, it's kind of hard to map for arbitrary blog topics so I can't give you a realistic example for how it would work there, but I guess if you made a post about new foreign recipe, it could probably be
> /<country of interest>/<topic of interest>/<object of interest>
> /japan/food/salmon
Your imagination is your only limit and I recommend you stop to think about what is the purpose of spending that much time on it, and you may find what you need.
/article/postNumber/Article-Title
e.g.:
https://theandrewbailey.com/article/266/Cinco-de-Mayo-Burger...
I've always been succinct in my titles, so getting overly long URLs isn't much of an issue, except on HN comments.
Even with that canonical url, you can still provide your own url shortening service a la example 3. Given the choice, I'd slightly prefer using a first party shortener that maps a single shortened link per piece of content versus third party one creating a shortened link per share.
year/month prefix is useful to readers if the content becomes stale quickly.
* If you have a subdomain for your blog(example: blog.mydomain.com) then you don't need /posts
* if you don't have subdomain, you can use /posts, to distinguish between regular pages of your site and blog articles. Because you might have mydomain.com/about and mydomain.com/contact pages
* Don't put metadata such as publish dates as it can be modified or changed in the future. Also it's relative.
* As for example 3, you would probably need it in case when you have lots of articles and there might be a slug collision. I wouldn't worry about that unless you are media organization
Having a date in the URL also signals how fresh the content is.
Google also state that descriptive URLs get higher click throughs via search than non descriptive.
Personally I'd go with example 1, option 2.
What I would ALSO do however, is add JSON-LD structured markup data to each post page, as I know Google uses it to classify and date your content.