Koki's personal blog

Koki's personal blog

Another fine, responsive site template by HTML5 UP.

Add a robots.txt to the site Hugo builds.

This article explains how to add robots.txt to the site Hugo builds.

Koki

1-Minute Read

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

  • 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

Reference articles

Hugo: Robots.txt File

Recent Posts

Categories