← Back to Notion formulas
URLsBeginner

Notion Formula to Create a URL Slug

Copy a Notion formula that converts a page title into a lowercase, hyphen-separated URL slug.

Notion Formula to Create a URL Slug cover

Use case

Create a URL-friendly slug from a title

Properties

Title

Use this formula to turn a title such as How to Organize Your Notes into the URL-friendly slug how-to-organize-your-notes.

if(
  empty(prop("Title")),
  "",
  replaceAll(
    replaceAll(
      lower(trim(prop("Title"))),
      "[^a-z0-9]+",
      "-"
    ),
    "^-|-$",
    ""
  )
)

What this formula does

StepExample
Trim spacesHow to Organize Your Notes
Convert to lowercasehow to organize your notes
Replace punctuation and spaceshow-to-organize-your-notes-
Remove hyphens at the endshow-to-organize-your-notes

The formula replaces each run of non-ASCII letters or numbers with one hyphen. Empty titles return a blank value.

Database setup

Create these properties in your Notion database:

PropertyTypeExample
TitleTitle or TextHow to Organize Your Notes
SlugFormulaThe formula above

If your source property is called Name, replace prop("Title") with prop("Name").

Add a fixed prefix

Use this variant when all slugs belong to the same content type:

"blog/" + replaceAll(
  replaceAll(lower(trim(prop("Title"))), "[^a-z0-9]+", "-"),
  "^-|-$",
  ""
)

This returns values such as blog/how-to-organize-your-notes.

Limit the slug length

Keep the first 60 characters when you need shorter slugs:

slice(
  replaceAll(
    replaceAll(lower(trim(prop("Title"))), "[^a-z0-9]+", "-"),
    "^-|-$",
    ""
  ),
  0,
  60
)

Check the result after slicing: it can end with a hyphen if the cut happens in the middle of a word.

Common problems

Accented letters and non-Latin characters are removed by this basic formula. If your titles include them, transliterate the title first or use a separate manually edited slug property.

If two titles produce the same slug, add a unique ID or page number. A formula cannot guarantee uniqueness across database rows.

If the formula returns an error, check that Title is a text or title property and that your Notion workspace supports regular expressions in replaceAll().