We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Runway, Shop

Runway routing and shop questions

Hi, I've been away from Perch almost 2 years.... I originally built a store in normal perch and the old paypal shop app, and it worked great but never launched because my friend was not ready to launch her business.

Now I'm back, and decided to re-build in runway and the new shop app. Things are working, I don't have errors or bugs, so I'll omit the diagnostic report. I'm using latest runway and shop app.

The issue is I have unwanted URL behaviour which is most likely due to me not quite grasping how routing works.

Here is my intended shop product path, which I have working and loads the product page fine:


It's a jewellery store, so an example product URL is:


The problem is that replacing the category name 'necklaces' with any word, say 'xyz' still loads the product page. I would prefer a 404 unless the URL is exactly correct!

My first question - what should the 'Product URL' setting be under 'Shop' in Perch General Settings? And what does this setting do? I currently have it set as: /shop/category/{slug}

Is that correct? Or should it be '/shop/{slug}/{slug}' ? Or something else?

For my category page, the path and URL pattern are: Path: /shop/category URL pattern: shop/[slug:category]

For my product page: Path: /shop/category/product URL pattern: shop/[slug:category]/[slug:product]

There's only 4 categories in a set called Products, for example 'products/necklaces/'.

Again, all the pages and category indexes are working and linking fine. I'm happy with everything except this URL thing whereby the product page loads regardless of the category name in the URL.


P K 0 points

  • 3 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

You could change the url pattern for your product page to be a list of options:

shop/[necklaces|category2|etc:category]/[slug:product] (https://docs.grabaperch.com/runway/routing/named-segments/)

But I guess that means an admin task if/when new categories are added.

Otherwise use PerchSystem::use_error_page(404) in your page code to check to see if the category and product exist before manually issuing a 404 (Runway 3 only).


P K 0 points

Ok, I see... so the behaviour is actually expected rather than a problem with my routing or settings.

Yes I want to avoid manually entering the category names in the URL pattern.

Ok.. so I guess error pages is something I hadn't got to in learning Runway. I was unaware I had to "teach" Perch when a product or category doesn't exist. Thanks for the tip. And if you or anyone can confirm what the 'product url' setting should be in the Perch general settings, and what that relates to, I'd be grateful.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's the path to a single product. It's used in places like search results.

It's not that you have to "teach" Perch anything. The routes match a pattern in the URL and serve an appropriate page. The logic on your page then can decide what to do. How your page responds to the URL is nothing to do with the routing system - its job is to map the URL to the correct master page, nothing more.

Here's an example filtering by categories


$slug1 = perch_get('categorySlug');
$slug2 = perch_get('categorySlug2');
$slug3 = perch_get('categorySlug3');
$slug4 = perch_get('categorySlug4');

if (!empty($slug1)) {
$filter_value = $slug1.'/';

if (!empty($slug2)) {
$filter_value .= $slug2.'/';

if (!empty($slug3)) {
$filter_value .= $slug3.'/';

if (!empty($slug4)) {
$filter_value .= $slug4.'/';

'template' => 'products/product_list.html',
'category' => $filter_value, // filter by category on URL
'filter' => 'stock_level', // list only products on stock
'match'=> 'gte', // list only products on stock
'value'=> 1, // list only products on stock
'paginate' => true,
'count' => 6,


P K 0 points

Thanks Lexi, I already have category filtering sorted, but I suppose your method is related to Duncan's suggestion to add options in the URL pattern. I'd prefer not to add the category names that way but I'll play around with it and see how I go.

Then this ''The problem is that replacing the category name 'necklaces' with any word, say 'xyz' still loads the product page. I would prefer a 404 unless the URL is exactly correct!'' should be trivial. With an if/else condition.