site:

slug(text)

Generates a slug for the given text. This is commonly done to convert, for example, a blog page title into an ID for that post.

In converting the text to a slug, slug will:

  • Convert text to lowercase
  • Convert spaces to dashes
  • Remove special characters except dashes, letters, numbers, and periods

Example: if post1.html contains:

---
title: The First Post
---

Here's the text of my first post.

Then the title can converted to a slug with:

$ ori slug post1.html/title
the-first-post

slug does not assume a particular file extension. If you wish to add an extension, you can use, for example, a template literal.