When creating a new landing page for your store's website, you can configure it as a custom search results page to promote specific products.
Although custom pages do not inherently fetch search data, the search-result-layout.customQuery
block from the Search Result app allows you to specify the query to render the desired search results for your users.
Before you begin
To build a custom search results page, familiarize yourself with the Search Result app to understand the blocks exported by this app, including the search-result-layout.customQuery
.
Instructions
-
Open your Store Theme app directory using your preferred code editor.
-
In the
routes.json
file, define a new path calledstore.custom#landing
. Replace thepath
value as needed for your scenario._10"store.custom#landing": {_10"path": "/landing"_10} -
In the
blocks.jsonc
folder, create a new file (e.g.,search-landing.jsonc
) to store the new custom search results page blocks. -
In the new file, declare the template name, such as
store.custom#landing
. Ensure the name matches the one declared in step 2. -
In the template's block list, add any theme block you want to build your new custom page. The
search-result-layout.customQuery
block is mandatory to define how the search query should be fetched. For example: -
Declare the blocks according to the search results custom page you wish to have. Below you can find an example of a custom search results template:
-
Save the changes made in your Store Theme app.
-
Open the terminal, log in to your VTEX Account and create a new development workspace.
-
Once logged into the desired account and workspace, link your Store Theme app to see your new custom page live.
-
Access your store's website using the following format:
{workspaceName}--{accountName}.myvtex.com/{pathName}
to see your new page live.
Once you are satisfied with the changes to your Store Theme, make your new theme content publicly available.