You do not have to generate a robots.txt
file in Magento directory because Magento generates the robots.txt content on demand and stores it in the database. It does not create a file, but you can view the content in your browser with the <domain.your.project>/robots.txt
link.
The config for robots.txt
file is stored in core_config_data
database table, you can check the value for design/search_engine_robots/default_robots
and design/search_engine_robots/custom_instructions
paths.
SELECT * FROM `core_config_data` WHERE `path` LIKE 'design/search_engine_robots/%'
You should update the config for robots.txt
from admin:
Admin sidebar > Content > Design > Configuration.
Find the Global configuration in the first row of the grid and click Edit.
Scroll down and expand the Search Engine Robots section to config rotbots.txt
Read more about config for robots.txt in the Magento official document https://experienceleague.adobe.com/docs/commerce-admin/marketing/seo/seo-overview.html#search-engine-robots
Conclusion: If you use the default Magento feature mentioned above to generate robots.txt, there is no robots.txt file in your Magento directory but the config for robots.txt is stored in the database.
If you create a robots.txt file manually, and put it in Magento directory>/pub/
, it will override the default Magento robots.txt file.