Add a robots.txt to the site Hugo builds.
This article explains how to add robots.txt to the site Hugo builds.
This article explains how to add robots.txt to the site Hugo builds.
The following lists are the table of contents about this article.
- Target audience
- Environment
- Preconditions
- Add setting to the config file
- Create the robots.txt under the layouts directory
- Example
- Reference articles
Target audience
- Those who want to add a robots.txt to the site Hugo builds.
Environment
- Hugo (v0.94.2+extended linux/amd64 BuildDate=unknown)
Preconditions
- Installed Hugo.
Add setting to the config file
Add the below code to top-level in the config file.
In this site case, I added the below code because the config file type is toml.
enableRobotsTXT = true
If you use a YAML type config file, add the below code.
enableRobotsTXT: true
If you use a JSON type config file, add the below code.
"enableRobotsTXT": true
Hugo will create the robots.txt that contents are below when generate the site.
User-agent: *
Create the robots.txt under the layouts directory
When you want to customize the robots.txt, you can use your robots.txt you create in the layouts directory.
Example
I will put the example, which is I set up this site. If you are interested in that, check it!
add robots.txt