How to show or hide elements by URL parameter
In TeleportHQ, a condition can read a value from the page's address, the part after ?, such as category=cakes in /products?category=cakes. First declare the parameter on the page: click Page settings above the canvas and add it under Page Params, with a Key name and a Default value. The Select Dynamic Property panel then lists it under URL Param, and a rule such as category = cakes shows an element only to visitors who arrive with that address. This gives you campaign variants (?offer=spring), category views (?category=cakes) and deep links to one part of a page (?tab=reviews).
Before you start
- A web app. Page Params show in Page settings of a web app. On a presentation website the section isn't there. See What's the difference between a website and a web app?
- A regular page. Details pages, which show one record each, have no Page Params.
- Role. You need a role that can edit the project, for example Designer.
Steps
The example shows a "Spring offer" banner only to visitors who open the page with ?offer=spring.
1. Declare the parameter on the page
- Open the page on the canvas. Above the top right of the canvas, click Page settings.
- Open the SEO tab and scroll to Page Params. Its description reads "Declare the URL search parameters this page accepts (e.g. ?category=food). Filters on this page and workflows that navigate here can then bind to these keys."
- In Key name, type
offer. A key starts with a letter and holds only letters, numbers and underscores. - In Default value, type what the page uses when the address has no
offer, or leave it empty. - Press Enter, or click outside the fields. The row is saved, and the line Declared keys: lists
offer.
To remove a parameter, click Remove (the cross) at the end of its row.
2. Put the rule on the element
- On the canvas, select the banner.
- In the right panel → Visual tab, turn on the Conditional Rendering switch.
- Click Bind, then Dynamic Properties Assignment Panel.
- In the Select Dynamic Property panel, open URL Param, click
offer, then click Bind property. URL Param sits right after state and props in the list. - Keep
=in the Operand list and typespringin the value box.
3. Publish and share the address
Publish the site. Share https://yourdomain.com/offers?offer=spring in the campaign. A visitor who opens it sees the banner; a visitor who opens /offers doesn't.
Three ways to use it
- Campaign variants:
offerwith rules=springon one banner and=newsletteron another. One page, one address per campaign. - Category views:
categorywith=cakeson a cakes intro and=breadon a bread intro. The list on the same page can filter by the same parameter. See How to filter a list. - Deep links:
tabwith=reviewson the reviews block, so a link from an email opens the page on the reviews. For a tab a visitor can also click, pair the parameter with a state: see Good to know.
Check that it worked
On the canvas, the parameter has its Default value, so an element whose rule needs another value is gone from the canvas. Click See all conditionally rendered nodes at the bottom center of the canvas to see it. On your published site, open the page with the parameter in the address, then without it.
Troubleshooting
URL Param isn't in the panel The page declares no parameter yet. Add one under Page Params in Page settings. For an element inside a component, URL Param is listed only while that component is used on exactly one page that declares parameters.
"Key must start with a letter and contain only letters, numbers, or underscores." Change the key, for example offer_code instead of offer-code.
"A parameter with this key already exists." The page already has that key. Use the row that exists.
The element never shows on the canvas The canvas uses the Default value. Set the Default value to the value the rule needs while you design, then change it back, or use See all conditionally rendered nodes.
The element shows on my site even without the parameter The Default value equals the value the rule tests. Clear it, or test for another value.
Good to know
- The parameter is read on every visit. The published page reads the address when it loads, with the Default value as fallback when the parameter is missing or empty.
- A state can start from the parameter. In Page settings → State, a state's starting value can be read from a URL Param. The published page then keeps the two in step: a button that changes the state updates the address, and the browser's back button updates the state.
- Several parameters. A page can declare any number of keys, and a rule can combine them with + condition, for example
offer=springandlang=de. - Downloaded code. The Next.js download reads the parameters. See How to download your site as code.