Magento 2 SEO Layered Navigation Creating Page TemplatesSEO Layered Navigation

« Back to Magento 2 SEO Layered Navigation

The FishPig Layered Navigation extension allows you to very quickly create page templates that can be applied to the automatically created pages in your layered navigation. This allows you to very quickly make each page different, which is great for customers and search engines. These templates are dynamic and can be applied to multiple pages in one go.

Loading a Page Template

When creating a page, there are 2 key fields: Target Object URL Key and Target Filter URL Key. These fields are used to determine which template to load for the current page. To understand these, it's important to understand the difference between the object URL and the filter URL.

The Object URL Key is the part of the URL that represents the object (the category or Splash Page) while the Filter URL Key represents the layered navigation options that have been converted to a URL. For the URL 'apparel/shoes/black.html', 'apparel/shoes' is the object URL Key (category) and 'black' is the filter URL Key (color=black). The .html is the URL suffix, but that isn't needed when creating a page template.

Both of these fields can take specific values or placeholders, allowing them to be used for multiple pages. Lets look at each field and see what we can do with it.

Target Object URL Key

As I said above, this field is for the part of the URL that is used by the object (category or Splash Page). This can take a static value (eg. apparel/shoes) or can take a dynamic placeholder (eg. apparel/*). Here are some examples to help you get started with your pages:

  • apparel/shoes - only applies to the apparel/shoes category
  • apparel/* - applies to all sub-categories of the Apparel category
  • */*/* - applies to any 3rd level category

If more than 1 page template matches the given URL, the template with the least placeholders will be used. If the URL was 'apparel/shoes', the first example above would be used rather than the second as the first example is more specific.

Target Filter URL Key

The Filter URL Key works in a very similar way to the Object URL Key except this is applied to the filter part of the URL. In this field, you can use attribute names to target specific attributes. Here are some examples.

  • {{color}} - applies to any page that has a single color filter and no other filter
  • {{color}}/* - applies to any page that has a color filter and any other filter
  • black/* - applies to any page that has a filter of 'black' and any other filter
  • {{color}}/*/* - applies to any page that has a color filter and 2 more filters.

The order of your filters depends on the attribute order in the Magento Admin.

On-Page Data

Once the correct page template has been loaded, it's time to add some data to the page. Once again we can use dynamic variables to make our pages different. Let's look at some examples:

  • {{color type="label"}} {{object position="2"}} - For the URL apparel/shoes/black, this would produce Black Apparel
  • {{color type="label"}} {{object position="2"}} - For the URL apparel/shoes/black,red, this would produce Black & Red Apparel

The position parameter denotes the position of the object you wish to use. If you had the Target Object URL Key of 'apparel/*', position 1 would be the Apparel category while position 2 would be the category matched by the '*'. By default the position parameter is '*', which will include all objects and will join them using the '&' character.

While adding the data to the page, you will notice the 'Name' field under the Attributes tab. What ever value you enter here can be retrieved using the '{{name}}' string. You can use this in other fields to quickly access what ever you have defined as the page name.