A simple URL solution I've used

I have employed a simple approach for clean URLs that is stock-Bubble.

Let’s say you have a thing, Team Member.
Team Member includes some fields: firstName (John), lastName (Doe), urlSlug (john-doe)
You want a URL that loads dynamically based on a Team Member’s urlSlug being in the URL like:

domain.com/team/john-doe

So, create a page called "team"

Give it a state called “Team Member” and let it be a thing, Team Member.

Have all of the content of the page elements refer to team’s Team Member state.
Maybe an image that is team’s Team Member’s profileShot
An h1 text element that is team’s Team Member’s firstName lastName
A p text element that is team’s Team Member’s bioText
Set the Page Title, SEO Title, SEO Description dynamically based on team’s Team Member

Create a workflow that fires on page load
Add an action like:

-Set state of Team
–Value = Search for Team Members[Constraint: urlSlug = Get path from URL{Get data from page URL- set this to Path}]:first item

This works for me so far. I hope it may work for somebody else needing clean URLs!

*There are some really nice plugins available for cleaning up your URLs for dynamic page content. Kudos to the excellent developers that continue to push Bubble’s capabilities with such fine work.

5 Likes

@jason1 I have a slightly modified version that could help make this a little cleaner and you wouldn’t have to use an advanced filter.

Add a field to the Thing called “URL Path”

Save whatever value you want to this field for each record. The benefit here is that your users can now customize the url path.

URL = domain.com/page-name/url-path

When you go to set your state to find that right Thing in the database, the value = Search for Thing with a constraint “URL Path = Get path from URL

To get “path” from URL, use the dynamic expression “Get data from page URL” and change “parameter” to “path”

With this method that uses a dedicated field for the path, it’ll be easier to validate and make sure it’s a unique path. You don’t want two records with the same value. With your example (and I know it was just an example), two team members could potentially have the same first and last name.


Gaby at Coaching No Code Apps

Courses, Private Coaching, and Custom App Development

Start Building Today :hammer_and_wrench:

10 Likes

Leave it to one of the Bubble Legends, @romanmg to make something more efficient and more awesome than before! Yes- for some blog projects I’ve used a field “urlSlug” and it is better as you avoid the filter. If it’s alright with you, I’ll shamelessly edit my first post to include this method as well!

4 Likes

I never tire of using the word “Slug” if I can :slight_smile:

Of course removing the “page-name” part is somewhat trickier.

We hack it by pointing mydomain.com at mydomain. bubbleapps.is/page-name using an html frame. But that is not ideal.

2 Likes