Merchandise category pages
On this page
With Algolia, you can merchandise products by creating category pages. For example, you could organize products into categories such as on-sale items, new arrivals, specific brands, product types (like smartphones), or colors.
To use an attribute in a Rule condition with filters, you must first declare it in attributesForFaceting
.
Before you begin
- Ensure the attribute you want to use to define categories is searchable.
- Declare the category page identifier as a searchable attributes for faceting.
Merchandise category pages
Merchandise category pages by configuring an identifier, setting a trigger (a condition), and selecting a strategy (a consequence).
Configure a category page identifier
- Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
- Select Create your first Rule and select Visual Editor.
- In the It all starts here section, select Choose category page.
- Click Configure, then I’m good, let’s go.
- Select a searchable facet as your Category page identifier.
- Optional: add a Custom subcategory separator if you’re using hierarchical categories. For example, for the hierarchical category:
Women / Coat / Raincoat
, enter/
as the custom separator. - Save your changes.
To update these settings later, click the gear icon in the top-right corner of the Visual Editor and select Category page identifiers.
Create a trigger
- Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
- Select Create your first Rule and select Visual Editor.
- In the It all starts here (trigger) section, select Choose category page.
- Choose a Category name: this is a value from your category page identifier.
- Click Apply.
Determine a consequence
In the What do you want to do? section, select how you want to merchandise the category page.
- Click Review and Publish to enable the category page rule.
- Click Save as Draft if you don’t want the rule to take effect yet.
Example: promote items on category pages until users start search searching
To promote items on category pages before users start searching, create a rule that’s triggered if:
- A user visits the category page
- The query is empty.
Create the rule in the Visual Editor
- Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
- Select Create your first Rule or New Rule and select Visual Editor.
-
In the It all starts here section, click Set query condition(s). In the Define the condition that triggers the rule:
- Toggle the Query option on.
- For Your Search, select Is and leave the text input empty.
- Toggle the Filters option on.
- Select a Filter name, for example,
category
. - Select a Value, for example,
Smartphone
. - Click Apply.
-
In the What do you want to do? section, select Pin items. The Choose items to pin pane opens:
- Under Pinned items, search for the item you wish to pin and enter a number as the Position to which you want to pin the item.
- Optional: click Pin another item and repeat this step.
- Click Apply.
- Save your changes.
- Click Review and Publish to enable the category page rule.
- Click Save as Draft if you don’t want the rule to take effect yet.
Create the rule in the Manual Editor
- Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
- Select Create your first Rule or New Rule and select Manual Editor.
-
In the Condition(s) section:
- Toggle the Query option on.
- Select Is from the menu and leave the text input empty.
- Toggle the Filters option on.
- In the Attribute name field, select the category page identifier, for example,
category
. - In the Attribute value field, select the category you want to merchandise, for example,
Smartphone
.
-
In the Consequence(s) section:
- Click Add consequence > Pin an item.
- Search for an Item you want to pin and define its Position.
- Optional: click Add consequence to pin more items.
- Optional: enter a description that describes what the rule does and enter a period during which the rule is valid.
- Save your changes.
Example: display banners on category pages
Category page banners operate similarly to search results banners, but a filter rather than a search query triggers them.
This example requires a UI that uses the Hits
widget from InstantSearch.js version 4.68.1 or later or Reach InstantSearch version 7.8.0 or later.
Create the rule in the Visual Editor
- Create a trigger
-
In the What do you want to do? section:
- Click Display banner.
-
Enter the Image URL for your banner and click Apply.
- Optional: enter a description that describes what the rule does and enter a period during which the rule is valid.
- Apply your changes.
A banner now displays on every visit to this category page.
Create the rule in the Manual Editor
- Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
- Select Create your first Rule or New Rule and select Manual Editor.
-
In the Condition(s) section:
- Toggle the Filters option on.
- Toggle the Query option off.
- In the Attribute name field, add your category page identifier, for example,
category
. -
In the Attribute value field, add the category for which you want to show a banner, for example,
Smartphone
. -
In the Consequence(s) section:
- Select Add consequence > Return Custom Data.
-
In the input field, enter a JSON object, for example,
{ "banner": "iPhone" }
. - Optional: enter a description that describes what the rule does and enter a period during which the rule is valid.
- Save your changes.
Now, every time a user visits the category page, the rule triggers and returns a JSON object as custom data. You can display this custom data in your UI as a banner.