Two or More Slugs dynamically in URL (yourpage.com/slugfirst/slugsecond)

Hi Community,
I need help with Slugs and am hoping someone has a good solution. Essentially, I’m hoping to use two slugs (each one is dynamically picked and relies on the past user selection) to go to a page that displays dynamic data…specifically, I’m aiming to get SEO benefits with the many slug combinations in the URL. For instance (homepage.com/user_selected_me_second/user_selected_me_first). Here’s an example of what I’m trying to achieve:

There has been a thread talking about this topic, however, I’m hoping to not open an external webpage (How-to: Dynamically Setting Slugs with Multiple Path Segments in url (/some/thing/here)) .I’d also prefer to use only slugs for clean URLs for SEO; however, am running into the problem that a page type cannot be set dynamically.

Does anyone know how to do this or have an easy solution? I’m not sure how’s the best way to get this to work or if I should be using parameters as well. Looking forward to hearing any solutions!!

Yes and No. Yes, I know how to do this. No, it is not an easy solution.

Firstly, consider what a slug is and how Bubble uses it. Bubble uses the slug to understand the dynamic data that should be set on the page (ie: a page has a content type and the slug is for the entry of that content type that Bubble should display) and the slug always comes as the second item in the path list (first item is the page name).

Second consider how Bubble allows us to send data to a page. In Bubble workflow actions or link elements, there is the ‘send data’ input in which you are expected to only put into that input a value of the type of content the page you are navigated to is set. So if the page has content type of Product, your data to send needs to be a product. If your page content type is set, you can not send any type of data other than that type.

Third, consider how you could navigate to a page with a content type (to have that slug picked up automatically by Bubble to display the dynamic data of the page type). You would use either the built in workflow action of go to page or a link element or a workflow action of open external website. If you choose to use the go to page action, you can not send two path items. If you use the link element or the workflow action open external page you can send two paths.

Fourth, consider the User Experience. If you use the go to page workflow action to send a user to the same page they are currently on, but simply change the slug or any number of path items, it works quickly, almost instantly and doesn’t reset the custom state values. If you use the link element or workflow action to open external URL then the whole entire page needs to reload, even if it is the same page they user is on and you are simply changing the slug or path items. Not an ideal situation if you are a good developer that considers user experience.

Fifth, consider how Bubble allows us to populate the data values to use in the SEO meta tags and Page header (where your structured data would go). Bubble doesn’t allow us to use dynamic expressions that reference other elements (ie: can not reference a group that has a type of data set) and you can only use dynamic expressions that reference the current page thing, a URL value or a search.

Sixth, consider how the difference between a single slug in a path list versus a second slug in the path list will affect your ability to know which item to use to determine which type of data you are displaying on the page. If it is the first slug, in your example, this would be the ‘user_selected_me_second’ (I’m pretty sure you have this backward in your example but I will use the values appropriately in order)

and the second slug would be ‘user_selected_me_first’…so how do you indicate to Bubble which path item to display? You need to know when the path item has or doesn’t have a certain number of items, so if the path list has just two items (page name and first slug) you would display ‘user_selected_me_second’ and if the path list has 3 items you would display ‘user_selected_me_first’.

Hope this helps. :wink:

2 Likes

Hi Boston,
Many thank you’s for your detailed thoughts which are all helpful and confirmed my logic flows within Bubble; hence making the potential solution puzzling. On your 6th point, the order is indeed correct, at least in appearance. I guess it might be easier to post where the idea came from as it’s an interesting directory format: https://www.angi.com/companylist/. Click on any type of project (Air Duct Cleaning, Awnings, etc.). Then scroll down and click on a city - let’s say Albany. Look at the URL → it says […]/albany/air-duct-cleaning.htm. Notice that Albany appears first in the URL eventhough it was selected second. Also notice the page (after selecting Albany) now shows actual service providers in Albany that provide air duct cleaning. In bubble, this seems puzzling as different Page Types are intersecting as you pointed out in points 1 - 5. This structure can be very useful for SEO. Do you have any idea how to replicate this functionality in Bubble?

The developer of the site positioned it as they wanted it to be positioned, likely for the purpose of the URL reading Albany Air Duct Cleaning rather than Air Duct Cleaning Albany, as the order in which the selection is made is inconsequential to how the developer forms the URL as they want it to be formed.

In my app I have a page which I form the URL to be /store/in/thailand/surat-thani/koh-samui because the country is first, then the province followed by the city. I chose to structure the URL this way and developed all functionality to follow this URL structure.

When creating your URL structure as a path list of items, it is important to organize it properly so that you can set up all the conditions necessary to track things accordingly. When working with parameters it makes no difference which order they come in the URL as you just simply reference the parameter itself, where with a path list you need to reference the path list item number.

Yes. It is difficult and complex and therefore time consuming to explain and setup. If you’d like to schedule a paid training session to go over this, you could find me via the Bubble coaching marketplace to schedule a training session. But the key is to not set a page content type and to always use the data to send workflow actions to send text.

This topic was automatically closed after 70 days. New replies are no longer allowed.