Add sitemap and robots.txt
When creating and adding your sitemap and robots.txt to your store, you may run into issues due to the read-only environment. You may receive errors such as the following:
The path ".:///app/app/" is not writable.
Path "/app/pub/static/sitemap.xml" is protected and cannot be used.
To best add these files, please review the steps below.
For Magento Commerce (Cloud) 2.2, you do not need to move the files or have a redirection added. If you used these workarounds before 2.2, you can return the files to the original locations and ticket to have the redirection removed.
Generate sitemap and robots
Access an environment fully configured for your site:
- For Starter, access an active branch for example
staging
- For Pro, access your
master
environment in Integration
Generate your sitemap.xml
and robots.txt
:
- Log into the Magento Admin.
- Navigate to Marketing > Site Map.
- Click Add Sitemap to generate a new site map. The file saves as
sitemap.xml
. - Navigate to Stores > Configuration > Design.
- Select options and update
robots.txt
. - Save your configuration.
For additional information, see Using a Sitemap and Search Engine Robots.
Import files to environment
If you accessed the environment directoy, you need to transfer the files from the environment to your local. For example, you can use rsync
or scp
through a terminal. If you completed the commands on your local, move the files to the correct location. The following example uses rsync
.
Move and add the files to your Git branch:
- SSH into the environment you created the files.
-
Use
rsync
to move the files to your local. The format of the command isrsync -azvP <source> <destination>
.rsync -azvP
@ :pub/media/ - SSH into the environment you want to move the files into.
-
Move the files into the
/pub/media/
directory using the rsync command:rsync -azvP pub/media/
@ :pub/media/ - Enter a ticket with Support to have URL rewrite rules added for
sitemap.xml
androbots.txt
.
When the redirects are completed, keep these files updated in that file location for your Git branches during deployment.