Pretty much every static site generator defaults to using the filename as the default slug. Most of them also offer some additional configuration for how the default slug is determined, thereby overriding the filename-based slug. In addition, most static site generators offer a slug front matter field that can be used to override the slug on a per page/post basis. For example, let's imagine a page on mysite.com in the /blog directory that has a filename of whats-slug.md. However, the front matter has defined slug: what-is-a-slug. In this case, the generated site will use http://mysite.com/blog/what-is-a-slug as the permalink (i.e. the URL) for the page.

Here are a few examples for some of the popular static site generator options and how they handle slugs and permalinks.

  • Hugo has granular control for how the default permalink and slug of a page/post is managed. In addition, you can define either a slug or url front matter overrides.
  • Jekyll relies on a default file-naming for posts but also offers granular control for how slugs and permalinks are determined for posts. If you would like to override how these are determined on a per post basis, you need to use the front matter permalink option.
  • Gatsby's default behavior is to use the file name as the slug, with the URL directory being the path. Overriding that on a per post basis requires the gatsby-plugin-slug plugin.