URLs are Directories

Just a friendly reminder that URL paths are directories. When you have an URL pathname that looks like /user/item/4, there’s an implicit understanding that /user and /user/item are also valid URLs. The underlying folder structure looks like this:

└── user
└── item
├── 1
├── 2
├── 3
└── 4


If you don’t want to create extra index pages, use - instead. E.g. user-item-4. There is nothing inherently better about using / instead of -, but the later comes without the implicit suggestions that there is an underlying folder.

├── user-item-1
├── user-item-2
├── user-item-3
└── user-item-4


This may not matter for consumer-facing sites, but there’s plenty of developer sites that get this wrong, too:

• GitHub will give you URLs like /qwtel/hydejack/tree/v8, but /qwtel/hydejack/tree doesn’t exist.

└── qwtel
└── hydejack
└── tree   # THIS FOLDER DOES NOT EXIST
└── v8 # WE PUT THINGS IN IT ANYWAY

• npm will give you organization-namespaced package URLs like /package/@platformparity/streams, but the organization pages don’t exist.

For some extra fun try /package, which — instead of returning a list of all packages — will redirect to /package/package 🙄

└── package             # symbolic link
├── package         # with folders in it
└── @platformparity # some of which don't exist
└── streams     # but have stuff inside anyway 🤷‍♂️

• Jekyll’s default permalink structure looks like /2018/06/06/urls-are-directories, but no pages for /2018, 2018/06, and /2018/06/06 are created. The proper URL is /2018-06-06-urls-are-directories

To recap: / has a special meaning in path names, while - does not. When you need to visually separate parts of your URL, but have no plans of introducing extra index pages, use -.