How do I add NOINDEX, FOLLOW
robots META tag to a custom 404 CMS page in Magento using XML, no matter what URL the page is served at?
By following the answer on this page, I was able to figure out how to target a specific Magento CMS Page (using the URL key) and then use a Layout Handle to change the robots META tag to NOINDEX, FOLLOW
. Which would work great for a static page.
But my page is meant for 404 errors and is served at many different URLs. The problem with the solution in the link above is that it only works if the URL matches the URL key of the page. (The URL key of my 404 page is no-route-2
) So if my 404 page is served at a URL that does not match the URL key ie. https://example.com/nothinghere
, the robots META tag will not be updated.
But if you go to https://example.com/no-route-2
it will work.
I need the robots META tag of my page to have NOINDEX, FOLLOW
no matter what URL it is served at.