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.
Prerequisites
- 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
Set Up a Dynamic Page with Type of Content
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.
Generate Slugs from Titles
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.
Ensure Slug Uniqueness
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.
Link to Dynamic Pages Using Slugs
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.
Handle Missing or Changed Slugs
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 working example
1SLUG GENERATION WORKFLOW:231. Create Product (name, description, price, etc.)42. Generate base slug from name:5 base_slug = Result of step 1's name (Bubble auto-formats)63. Check uniqueness:7 Search for Products (slug = base_slug):count84. If count > 0:9 Append number: base_slug & "-" & (count + 1)105. Set a thing's slug:11 Thing: Result of step 112 Slug: final unique slug1314URL STRUCTURE:15yourapp.com/product/blue-running-shoes16yourapp.com/blog/how-to-build-an-app17yourapp.com/profile/john-doe1819PAGE CONFIGURATION:20- Page: product21- Type of content: Product22- Current Page Product = loaded by slug match2324404 HANDLING:25- Page is loaded → Only when Current Page Product is empty:26 → Go to page: 404Common mistakes when generating unique URLs in Bubble
Why it's a problem: Using 'Make changes to a thing' to set slugs
How to avoid: Always use the 'Set a thing's slug' workflow action, not a custom text field.
Why it's a problem: Not checking for slug uniqueness
How to avoid: Search for existing records with the same slug before setting it. Append a number if a collision exists.
Why it's a problem: Changing slugs when titles are edited
How to avoid: 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.
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want clean URLs in my Bubble.io app like /product/blue-running-shoes instead of /product/1234567890. How do I set up slugs, auto-generate them from product names, and ensure uniqueness?
Set up slug generation for the Product data type. Auto-generate slugs from product names on creation. Check for uniqueness and append numbers if needed. Configure the product page to use slugs.
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.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation