Usage
Add robots.php file in the theme directory.
For example:
Theme: placeholder-theme
Location: wp-content/themes/placeholder-theme/robots.php
The robots.php file is used to dynamically generate the robots.txt content for the theme. The file is accessed when search engine crawlers request the robots.txt file for SEO directives.
In the repository nginx/app/locations.conf add these lines.
This configuration allows each theme to manage its own robots.txt file through a dynamic robots.php script. The try_files directive checks for the existence of the file, and if not found, redirects to the specified PHP script.
Sample robots.php file:
Specifies the location of the XML sitemap for search engines to find and index.
Last updated
Was this helpful?