trwnh.com/unified.test.hugo/content/meta/uris-and-slugs.md

2.8 KiB

+++ title = "URI design and slug choice" summary = "Some guidelines on where to put content files." updated = 2024-10-16 toc = true +++

Sections

Why sections?

Web pages generally benefit from having some context associated with them. If they don't, then it's fine to stick them directly under the root of your domain name. These "top-level" pages are standalone and don't need any additional context. Common examples include:

  • /about
  • /contact
  • /search

Defining a section

When defining a section, it should have a clear reason to exist, and it should be defined narrowly enough that it doesn't overlap with any other section. Within each section, typically aim for zero nesting. The aim is for each section to represent a logical bucket into which I can put stuff, and then later be able to easily find that stuff.

Currently existing sections

  • /monologues = self-replies and other passing stream-of-consciousness stuff
  • /theorycrafting = exploring ideas and concepts
  • /essays = writings intended to convince

Future potential sections

  • /posts = a section that i can hook up to a micropub server or something, which i would use for primarily "social media" style use-cases. it's very likely that most things in here will be indieweb post type "note", but i don't actually care what the post type is, and it doesn't actually matter what the post type is. as far as i'm concerned and as far as this section is concerned, they're all posts.
  • /meta = stuff about this website itself, like this document
  • /unstable = stuff that might disappear at any time, kind of a dumping ground

Slugs

Slugs are not titles

The slug SHOULD NOT be thought of as linked to the title in any way. You can use the title as a suggestion for a slug, but the slug has no bearing on the title. This is because the title can change freely without affecting the slug. They are separate things.

Slugs should start with the primary subject

The first part of the slug SHOULD be the primary subject of whatever the page/article/writing is about. For example, a content piece in /monologues with the title "specs aren't enough" may not actually be primarily about "specs". It is in fact about fedi. So the slug should be fedi-specs-arent-enough and not specs-arent-enough. Note that this can still be ambiguous because it is unclear whether the primary subject is "specs" or "fedi specs". I don't have a good solution for this ambiguity, but it is better to keep "fedi" in there, because a potential reader seeing only specs-arent-enough will have no way of knowing that the content is about fedi in particular.

Slugs should match the folder name

Custom slugs SHOULD NOT be set. If it's good enough for your filesystem, it should be good enough for your URI, and vice-versa.