Creating robots files for cross-border stores
This guide explains how to develop and release a Robots app to manage ´robots.txt´ files for cross-border stores using Store Framework.
A robots.txt file controls which folders or files search engines can crawl on a website. Given its impact on store SEO, the following steps explain how to create robots.txt files for cross-border stores.
This guide only applies to cross-border stores. If your store isn't cross-border, see this guide.
robots.txt file structure
Below is the basic structure of a robots.txt file:
User-agent: Specifies the search engine robot to which the following rules apply. To apply the same rules to all robots, use*.Disallow: Defines the paths (relative to the root directory) of files or folders that the search engine specified inUser-agentmust not index.Allow: Specifies the paths of files within aDisallowedfolder that can be crawled and indexed.
You must adjust these directives based on your scenario.
Before you begin
This feature is available for stores using the vtex.edition-store@3.x Edition app or newer. To check which Edition app is installed on your account, run vtex edition get. If your store is using an older Edition, open a ticket with VTEX Support requesting the installation of vtex.edition-store@5.x.
Instructions
Follow the steps below to develop your Robots app:
-
Use the command below to clone the
store-theme-robotsapp boilerplate repository._10git clone https://github.com/vtex-apps/store-theme-robots -
Once successfully cloned, open the local app directory in your code editor.
-
Open the
manifest.jsonfile and edit thevendorfield with the name of the developing account._10{_10"vendor": "myaccount",_10"name": "robots",_10"version": "0.0.1",_10"builders": {_10"sitemap": "0.x"_10},_10..._10} -
Inside the
sitemap/robotsfolder, create a.txtrobots file for each supported locale binding. The name of each file must be theidvalue of its respectivebinding.Follow this tutorial to check the store binding
ids.Your app folder should have a structure similar to the following:
_10store-theme-robots_10├── manifest.json_10├── README.md_10└─┬ sitemap_10└─┬ robots_10├── 706e9126-d0fc-47de-9o2d-5f9649e61877.txt_10└── 748aafcf-1674-456d-9ffc-7ddb3f26e43f.txt -
Edit each file in the
sitemap/robotsfolder with the content you want for yourrobots.txtfiles. -
Once everything is set up, use the terminal and VTEX IO CLI to log in to the VTEX account you're currently working in.
-
Run
vtex use {workspace}to select a developer environment.Replace the values between curly brackets based on your scenario.
-
Run
cd store-theme-robotsto go to the local app directory. -
Run
vtex linkto link your new app to your development workspace. -
Check the
robotsfile generated for each store by accessinghttps://{workspace}--{account}.myvtex.com/{locale}/robots.txton your browser. -
Follow the guide Deploying a new app version to test your Robots app in a production workspace and, once you're satisfied with the result, promote it to master.
The Robots app must be tested in a production workspace.
Now you're ready to check your store's robots.txt files by accessing https://{account}.myvtex.com/{locale}/robots.txt in your browser, replacing the values between the curly brackets based on your scenario.