# How to generate unique URLs in Bubble

- Tool: Bubble
- Difficulty: Beginner
- Time required: 10-15 min
- Compatibility: All Bubble plans
- Last updated: March 2026

## TL;DR

Generate unique, SEO-friendly URLs in Bubble using the 'Set a thing's slug' action. Slugs are human-readable identifiers (e.g., my-product-name) appended to dynamic page URLs. Auto-generate slugs from titles by converting to lowercase, replacing spaces with hyphens, and removing special characters. Check for uniqueness by searching existing slugs before saving.

## Generate Unique URLs with Slugs in Bubble

This tutorial shows you how to create clean, human-readable URLs for your Bubble app pages using slugs. Instead of long unique IDs, your URLs will look like yourapp.com/product/blue-running-shoes.

## Before you start

- A Bubble account with an active app
- A Data Type with content that needs unique URLs
- Basic understanding of dynamic pages

## Step-by-step guide

### 1. Set Up a Dynamic Page with Type of Content

Create a page (e.g., 'product') and set its Type of content to your Data Type (Product). This enables the URL pattern: yourapp.com/product/[slug]. When users visit this URL, Bubble loads the Product matching the slug automatically into 'Current Page Product'.

**Expected result:** A dynamic page that loads data based on the URL slug.

### 2. Generate Slugs from Titles

In the workflow where you create a new record, after the 'Create a new thing' action, add the 'Set a thing's slug' action (found under Data Things). Set the thing to 'Result of step 1' and the slug to a formatted version of the title: 'Result of step 1's name :lowercase :find & replace (regex pattern for spaces and special chars)'. A simpler approach: just pass the title directly — Bubble auto-formats slugs to be URL-safe.

> Pro tip: Bubble's 'Set a thing's slug' action automatically converts text to URL-safe format (lowercase, hyphens for spaces). You do not need to manually sanitize in most cases.

**Expected result:** Each new record gets a clean, URL-safe slug derived from its title.

### 3. Ensure Slug Uniqueness

Before setting the slug, check if it already exists: Search for Products where slug = generated_slug. If the count is greater than 0, append a number (e.g., 'blue-shoes-2'). Implement this in a backend workflow that tries the base slug, checks uniqueness, and appends an incrementing number until unique. Save the final slug using 'Set a thing's slug'.

**Expected result:** Every slug is unique, preventing URL collisions.

### 4. Link to Dynamic Pages Using Slugs

When creating links to dynamic pages, use the 'Go to page' action with 'Data to send' = the record. Bubble automatically constructs the URL with the slug. In Link elements, set destination to the dynamic page and data to the record. The resulting URL will be: yourapp.com/product/record-slug.

**Expected result:** Navigation links generate clean URLs using slugs.

### 5. Handle Missing or Changed Slugs

If a slug changes (e.g., title is edited), old URLs break. Consider: (1) Never change slugs after creation. (2) Store old slugs in a 'slug_history' list field and add a redirect mechanism. (3) On the page, if no data is found for the slug, redirect to a 404 page. Add a 'Page is loaded' condition: if Current Page Product is empty → Go to 404 page.

**Expected result:** Old URLs are handled gracefully with redirects or 404 pages.

## Complete code example

File: `Workflow summary`

```text
SLUG GENERATION WORKFLOW:

1. Create Product (name, description, price, etc.)
2. Generate base slug from name:
   base_slug = Result of step 1's name (Bubble auto-formats)
3. Check uniqueness:
   Search for Products (slug = base_slug):count
4. If count > 0:
   Append number: base_slug & "-" & (count + 1)
5. Set a thing's slug:
   Thing: Result of step 1
   Slug: final unique slug

URL STRUCTURE:
yourapp.com/product/blue-running-shoes
yourapp.com/blog/how-to-build-an-app
yourapp.com/profile/john-doe

PAGE CONFIGURATION:
- Page: product
- Type of content: Product
- Current Page Product = loaded by slug match

404 HANDLING:
- Page is loaded → Only when Current Page Product is empty:
  → Go to page: 404
```

## Common mistakes

- **Using 'Make changes to a thing' to set slugs** — Bubble has a dedicated 'Set a thing's slug' action that properly formats and stores the slug. Using 'Make changes' on a custom text field does not integrate with Bubble's URL routing. Fix: Always use the 'Set a thing's slug' workflow action, not a custom text field.
- **Not checking for slug uniqueness** — Duplicate slugs cause the wrong record to load on dynamic pages. Fix: Search for existing records with the same slug before setting it. Append a number if a collision exists.
- **Changing slugs when titles are edited** — Changing slugs breaks existing URLs, bookmarks, and search engine rankings. Fix: Set slugs once at creation time and never change them, even if the title changes.

## Best practices

- Use the 'Set a thing's slug' action, not a custom text field.
- Set slugs at record creation time and never change them.
- Check for uniqueness before setting a slug.
- Keep slugs short and descriptive — under 50 characters.
- Handle 404 cases when a slug does not match any record.
- Include slugs in your XML sitemap for SEO.

## Frequently asked questions

### Can I customize the slug format?

Bubble auto-formats slugs (lowercase, hyphens). You can pre-process the text before passing it to 'Set a thing's slug' if you want additional formatting, like removing common words.

### What characters are allowed in slugs?

Slugs support lowercase letters, numbers, and hyphens. Bubble automatically strips or converts other characters.

### Can I use slugs on the free plan?

Yes. Slugs and dynamic pages work on all Bubble plans.

### How do I redirect old slugs to new ones?

Store old slugs in a list field. On page load, if the current slug does not match but is in the history list, redirect to the correct URL. For complex URL management, RapidDev can implement proper redirect systems.

### Do slugs affect SEO?

Yes. Clean, descriptive URLs are a minor SEO ranking factor. 'yourapp.com/product/blue-running-shoes' is better than 'yourapp.com/product/1609123456789x123456789'.

### Can two different Data Types have the same slug?

Yes. Slugs are unique per Data Type. A Product and a BlogPost can both have the slug 'best-picks-2026' because they are on different pages.

---

Source: https://www.rapidevelopers.com/bubble-tutorial/create-a-generator-for-unique-urls-in-bubble
© RapidDev — https://www.rapidevelopers.com/bubble-tutorial/create-a-generator-for-unique-urls-in-bubble
