优秀 URL 设计示例 (2023)
Examples of Great URL Design (2023)

原始链接: https://blog.jim-nielsen.com/2023/examples-of-great-urls/

Kyle Aster 强调仔细设计 URL 的重要性,因为它们在浏览器和设备等各种平台上具有通用性,并且其用途超出了简单的导航。 他解释了 URL 如何发挥多种作用——定位脚本、出现在书籍的脚注或附录中,以及充当 QR 码或物联网设备按钮等可操作的触发器。 他引用了 StackOverflow 和 Slack 等网站,其中 URL 结构的设计方式使机器和人类都可以轻松理解。 他喜欢 URL 反映网站域语义的网站,并引用了 GitHub、NPM 和 unpkg 等示例。 最后,他邀请读者分享他们最喜欢的 URL 设计。

Notion 的网址系统使用稳定的 URL 格式,无论页面重命名、重组或移动。 格式如下:notion.so/:account/Page-Title:pageID。 当页面标题因重命名而发生变化时,新 URL 与旧页面 ID 保持不变,确保连续性。 还可以使用 notion.so/:account/:pageID 进行导航,它直接引导至相应的页面。 如果改用通用术语后跟页面 ID,则仍会重定向到正确的目的地。 这种设计方面提供了便利,特别是在从概念数据库提取数据并将其传输到替代工具期间,因为链接保持一致,而不依赖于准确的页面标题或与命名约定相关的复杂性。 URL 排列将层次结构详细信息隐藏在导航系统中,而不是通过 URL 结构显式显示。 因此,页面重定位仍然有效。 尽管可能存在局限性,但该策略已被证明是实用且有效的。 演示者概述了六项 URL 指南,强调: * 唯一性 – 每个资源对应一个 URL。 * 持久性 – 无需更改现有 URL,消除依赖性。 * 可管理性 – 跨站点部分的一致逻辑应用程序,排除复杂的异常并避免复杂化。 * 可扩展性——轻松扩展逻辑。 * 简短 – 最小化字符长度。 * 部分变化 – 目标短语允许轻微修改。 第 1 条规则最为重要,而第 2 条规则的重要性则排在第二位。 规则 3、4、5 和 6 分别根据重要性递减而遵循。 SEO 友好的 URL 满足所有上述 URL 准则。 首选 URL 结构显示为 example.com/\[short-namespace\]\[\[unique-slug\]]。 下面提供了该 URL 结构的简要说明: - \[短命名空间\] 由一两个字母符号组成,标识网页类别,独立于整个网站架构。 - \[Unique-Slug\] 仅包含小写字母、数字、连字符,并且不包括重复的连字符实例或最后的连字符或下划线。 如果编辑控制权完全落在作者手中,则仅使用口语。 在注意到个人对蛞蝓的偏好的同时,作者建议
相关文章

原文

Here’s Kyle Aster on why thoughtful URL design is important (in 2010):

URLs are universal. They work in Firefox, Chrome, Safari, Internet Explorer, cURL, wget, your iPhone, Android and even written down on sticky notes. They are the one universal syntax of the web. Don’t take that for granted.

I love this reminder of the ubiquity of URLs. They’re not just for typing into browser bars. They’re used in a plethora of ways:

  • As targets for scripting and scraping and other programmatic data retrieval.
  • As references, printed in the footnotes and appendixes of physical books.
  • As actionable triggers accessible via physical mediums, e.g. scannable QR codes or IoT device buttons.
  • And more!

When I reflect on examples of great URL design[1] I’ve encountered through the years — URLs that, when I saw them, I paused and thought “Wow, that’s really neat!” — these are a few that come to mind.

StackOverflow

StackOverflow was the first place I remember encountering URLs that struck a nice balance between the needs of computers and humans.

The URLs follow a pattern like this:

/questions/:id/:slug

:id is a unique identifier for the question that reveals nothing about the content. :slug, on the other hand, is a human-readable paraphrasing of the question that allows you to understand the question without ever actually going to the website.

The beauty is :slug is an optional parameter in the URL. For example:

stackoverflow.com/questions/16245767

Tells you nothing about the question being asked but it’s a valid URL that allows a server to easily find and serve that unique piece of content.

But StackOverflow also supports the :slug part of the URL which allows humans to quickly understand the contents living at that URL.

stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript/

As noted, the :slug is optional. It is not required by the server to find and serve the contents in question. In fact, it can easily be changed over time without without breaking the URL (which I find quite elegant).

Granted, it can also be used deceptively. For example, this is the same URL as above but it portends completely different contents (without breaking the link):

stackoverflow.com/questions/16245767/how-to-bake-a-cake

But hey, trade-offs in everything.

Slack

I remember when Slack launched a marketing campaign to educate people about the product. They used the language of the marketing campaign – “Slack is...” — in the page copy as well as in the URLs, e.g.

  • slack.com/is
  • slack.com/is/team-communication
  • slack.com/is/everything-in-one-place
  • slack.com/is/wherever-you-are

I remember being so intrigued at this effort to bring the design of the story-telling campaign all the way up into the URLs themselves.

Since then, I’ve always found delight in URLs that try to form natural languages sentences — slack.com/is/team-communication — rather than concatenate a series of hierarchical keywords — slack.com/product/team-communication.

Speaking of doing fun things with sentence structure in your URLs...

Jessica Hische

Jessica Hische has her website under a .is domain (which is for Iceland, apparently).

jessicahische.is

She riffs on this fun third-person form of “I am” across her site. For example, click on “About” in the primary navigation and it takes you to:

jessicahische.is/anoversharer

That’s fun! mydomain.com/about is clear too, but I love the whimsy of describing the “about” and doing it in sentence structure.

All of the nouns in her primary navigation follow this pattern, as well as her individual pieces of work. Like this writeup about one of her holiday culinary packaging gigs has the URL:

jessicahische.is/sofulloffancypopcorn

Fun!

URLs as Product

I’ve always loved services whose URLs map nicely to their domain semantics. For example, GitHub’s URLs map really well to git semantics like the three dot diff comparison in git:

/:owner/:project/compare/ref1...ref2

e.g.

github.com/django/django/compare/4.2.7...main

For technical products, this ability to navigate a website without necessarily seeing the user interface is a cool superpower.

NPM is somewhat similar. Want to see react-router on NPM? You don’t have to go to NPM’s home page and click around or use their search box. Once you become familiar with their site structure, you know you can lookup a package using:

/package/:package-name

e.g.

npmjs.com/package/react-router

Want to lookup a specific version of a package?

/package/:package-name/v/:semver

e.g.

npmjs.com/package/react-router/v/5.3.4

These kinds of shortcuts are super useful when you’re using a particular product. In the case of NPM, you’re hunting through your package.json and need to lookup some details of a specific package pinned at a specific version, you can navigate to NPM’s details of that package by merely identifying the version you want and typing the details into a URL bar.

NPM CDNs like unpkg do a good job at following these semantics as well. Want a file from a published package? The homepage of unpkg says:

unpkg.com/:package@:version/:file

In cases like this, the URL can be the product itself which makes its design all the more vital[2].

What’s Yours?

These are a few examples of URLs I’ve enjoyed using or seeing over the years. I’m sure there are others, but I’d be curious to know what your favorites are? Blog ’em!

联系我们 contact @ memedata.com