A URL Policy for Web Projects
Published on August 22, 2013 (↻ February 5, 2024), filed under Development (RSS feed for all categories).
This and many other posts are also available as a pretty, well-behaved ebook: On Web Development.
Do your projects suffer from URL inconsistencies? I just noticed how mine do. I also noticed that I did some unnecessary things, like omitting protocols when they were actually useful. And I noticed that I’ve seen similar problems in corporate projects before. So I jotted down a quick “policy.”
-
Use the shortest available, non-redirecting URL. For example, make all site references relative if possible; root-relative URLs (
/foo
) may be allowed on pages that serve as their own error pages. And, of course, omit “index.html” and other files names if they effectively serve as a DirectoryIndex. (Reason: more focused.) -
Don’t omit the protocol unless the host site is available through both http and https. (Reason: faster—to avoid http to https redirects, assuming a http host site with links to target sites that live on https.)[There are still use cases for protocol-less URLs but this here has been outlived by increased focus on security.] -
Prefer https over http references. (Reason: more secure.)
-
Be consistent per site. (Reason: more maintainable.)
Mileage may vary, so this is more of an idea for other projects’ URL policies. Maybe you have a preference for absolute URLs. Maybe you have an SSL certificate, in which case you want to force https. Maybe you’re not as concerned about consistency. And maybe you see something that I missed, or found something to work better?
About Me
I’m Jens (long: Jens Oliver Meiert), and I’m a frontend engineering leader and tech author/publisher. I’ve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, I’m a contributor to several web standards, and I write and review books for O’Reilly and Frontend Dogma.
I love trying things, not only in web development (and engineering management), but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (Be critical, interpret charitably, and give feedback.)
Read More
Maybe of interest to you, too:
- Next: The Art of Saying Thank You, One Thousand Times
- Previous: Surveillance Kills Democracy
- More under Development
- More from 2013
- Most popular posts
Looking for a way to comment? Comments have been disabled, unfortunately.
Get a good look at web development? Try WebGlossary.info—and The Web Development Glossary 3K. With explanations and definitions for thousands of terms of web development, web design, and related fields, building on Wikipedia as well as MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.