5 ms·
this is how I do URLs. My personal battle proven URL rules. URL-rules URL-Rule 1: unique (1 URL == 1 resource, 1 resource == 1 URL) URL-Rule 2: permanent (th
by franze 4y ago
this is how I do URLs. My personal battle proven URL rules.
URL-rules
URL-Rule 1: unique (1 URL == 1 resource, 1 resource == 1 URL)
URL-Rule 2: permanent (they do not change, no dependencies to anything)
URL-Rule 3: manageable (equals measurable, 1 logic per site section, no complicated exceptions,
no exceptions)
URL-Rule 4: easily scalable logic
URL-Rule 5: short
URL-Rule 6: with a variation (partial) of the targeted phrase the page wants to get found for
URL-Rule 1 is more important than 1 to 6 combined, URL-Rule 2 is more important than 2 to 6 combines, … URL-Rule 5 and 6 are a trade-of. 6 is the least important. A truly search optimized URL must fulfill all URL-Rules.
My preferred URL structure is:
https://www.example.com/%short-namespace%/%unique-slug%
https:// https:// – protocol
www – subdomain
example – brand
.com – general TLD or country TLD
%short-namespace% – one or two letter that identify the pagetype, no dependency to any site hierachy
%unique-slug% – only use a-z, 0-9, and – in the slug, no double — and no – or – at the end.
Only use “speaking slugs” if you have them under your total editorial control.
i.e.:
https://www.example.com/a/artikel-name
https://www.example.com/c/cool-list
https://www.example.com/p/12345 (does not fulfill the least important URL-Rule 6)
https://www.example.com/p/12345-prouct-name
- eyelidlessness 4y agoI have no idea why your text is grey because this is all very good advice. The character class limitations might sound arbitrary but no one who takes this seriously is handling Unicode in URLs because there are too many risks. (Not that I’m an authority on the subject but my most regrettable StackOverflow contribution is the regular expression for IRIs which has some flaws and I’ll never revise it because it’s not a good idea.)
- teddyh 4y agoYou’re not thinking very long-term. As the article explains, for long-term resources, your should put some form of date in the URL, such that you do not continually deplete the namespace. For example, suppose that you once wrote an article on AI, in, say, 2008, with the URL https://www.example.com/a/current-developments-in-ai https://www.example.com/a/current-developments-in-ai When the subject, in this case AI, suddenly changes in later years, and you want to write an update, you’ll be forced to use this monstrosity of a URL: https://www.example.com/a/current-developments-in-ai-2 https://www.example.com/a/current-developments-in-ai-2 Why not start with https://www.example.com/a/2008/current-developments-in-ai https://www.example.com/a/2008/current-developments-in-ai so that you can then create https://www.example.com/a/2023/current-developments-in-ai https://www.example.com/a/2023/current-developments-in-ai ? (This will also benefit readers, similarly how HN likes having the year parenthesized in the submitted title.)
- kevin_thibedeau 4y agoYou just made an SEO expert die of a heart attack. They're paranoid about dateable content.
- teddyh 4y agoYou say that like it’s a bad thing.
- MrVandemar 4y agoIf a date is something that helps categorise something in a sane, indexable way, and SEO experts don't like them, they can go and [obscenity] an [animal-noun] with a rusty [ambiguous-from-context] and [illegal-act] and put it in their pipe and smoke it. Metadata matters.
- jefftk 4y agoI'd rather occasionally have an awkward url than need to put the date in every time. I've written ~2k posts and 1% ended up with suffixes like this (ex: https://www.jefftk.com/p/nomic-report-ii https://www.jefftk.com/p/nomic-report-ii). And most of those were published in the same year as the original post anyway.
- crooked-v 4y agoJust give each entry a unique ID and put it in the URL: https://www.example.com/a/abcdefghi/current-developments-in-ai https://www.example.com/a/abcdefghi/current-developments-in-... Then if you ever see the need to shuffle around your site, you can do redirects based on unique ID without needing to keep track of slugs or other metadata.
- wruza 4y agoAlso make it accessible by id only, so that: https://www.example.com/a/abcdefghi/current-davalopments-in-ai https://www.example.com/a/abcdefghi/current-davalopments-in-... https://www.example.com/a/abcdefghi/current-developments-in-ai https://www.example.com/a/abcdefghi/current-developments-in-... https://www.example.com/a/abcdefghi https://www.example.com/a/abcdefghi are all the same.
- garganzol 4y agoInteresting, but what is the purpose of %short-namespace%? To me, it just adds the noise. Or maybe it's there to separate e.g. articles vs. products?
- franze 4y agorule 3 manageable = measurable beeing able to seperate easily in analytics tools apple from pears, products from article pages from lispages. while still having no dependencies in there
- perilunar 4y ago> URL-Rule 1 is more important than 1 to 6 combined implies that rules 2 to 6 combined have negative value.