Guides / Managing results / Rules / Merchandising

Merchandise category pages

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

  1. Ensure the attribute you want to use to define categories is searchable.
  2. 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

  1. Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
  2. Select Create your first Rule and select Visual Editor.
  3. In the It all starts here section, select Choose category page.
  4. Click Configure, then I’m good, let’s go.
  5. Select a searchable facet as your Category page identifier.
  6. 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.
  7. 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

  1. Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
  2. Select Create your first Rule and select Visual Editor.
  3. In the It all starts here (trigger) section, select Choose category page.
  4. Choose a Category name: this is a value from your category page identifier.
  5. 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

  1. Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
  2. Select Create your first Rule or New Rule and select Visual Editor.
  3. In the It all starts here section, click Set query condition(s). In the Define the condition that triggers the rule:

    1. Toggle the Query option on.
    2. For Your Search, select Is and leave the text input empty.
    3. Toggle the Filters option on.
    4. Select a Filter name, for example, category.
    5. Select a Value, for example, Smartphone.
    6. Click Apply.
  4. In the What do you want to do? section, select Pin items. The Choose items to pin pane opens:

    1. 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.
    2. Optional: click Pin another item and repeat this step.
    3. Click Apply.
  5. 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

  1. Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
  2. Select Create your first Rule or New Rule and select Manual Editor.
  3. In the Condition(s) section:

    1. Toggle the Query option on.
    2. Select Is from the menu and leave the text input empty.
    3. Toggle the Filters option on.
    4. In the Attribute name field, select the category page identifier, for example, category.
    5. In the Attribute value field, select the category you want to merchandise, for example, Smartphone.
  4. In the Consequence(s) section:

    1. Click Add consequence > Pin an item.
    2. Search for an Item you want to pin and define its Position.
    3. Optional: click Add consequence to pin more items.
  5. Optional: enter a description that describes what the rule does and enter a period during which the rule is valid.
  6. 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

  1. Create a trigger
  2. In the What do you want to do? section:

  3. Click Display banner.
  4. Enter the Image URL for your banner and click Apply.

  5. Optional: enter a description that describes what the rule does and enter a period during which the rule is valid.
  6. Apply your changes.

A banner now displays on every visit to this category page.

Create the rule in the Manual Editor

  1. Go to the Rules section in the Algolia dashboard. Select the index to which you want to add a rule.
  2. Select Create your first Rule or New Rule and select Manual Editor.
  3. In the Condition(s) section:

  4. Toggle the Filters option on.
  5. Toggle the Query option off.
  6. In the Attribute name field, add your category page identifier, for example, category.
  7. In the Attribute value field, add the category for which you want to show a banner, for example, Smartphone.

  8. In the Consequence(s) section:

  9. Select Add consequence > Return Custom Data.
  10. In the input field, enter a JSON object, for example, { "banner": "iPhone" }.

  11. Optional: enter a description that describes what the rule does and enter a period during which the rule is valid.
  12. 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.

Did you find this page helpful?