hugo/docs/content/extras/robots-txt.md

37 lines
943 B
Markdown
Raw Normal View History

2015-12-08 16:13:09 -05:00
---
2016-01-06 23:11:02 -05:00
lastmod: 2016-01-06
date: 2015-12-08
2015-12-08 16:13:09 -05:00
menu:
main:
parent: extras
2016-12-11 19:55:36 -05:00
next: /extras/datafiles
prev: /extras/crossreferences
2016-01-06 23:11:02 -05:00
title: Custom robots.txt
2015-12-08 16:13:09 -05:00
---
2016-01-06 23:11:02 -05:00
Hugo can generated a customized [robots.txt](http://www.robotstxt.org/) in the
[same way as any other templates]({{< ref "templates/go-templates.md" >}}).
2015-12-08 16:13:09 -05:00
To enable it, just set `enableRobotsTXT` option to `true` in the [configuration file]({{< ref "overview/configuration.md" >}}). By default, it generates a robots.txt, which allows everything, with the following content:
2015-12-08 16:13:09 -05:00
2016-01-06 23:11:02 -05:00
```http
User-agent: *
```
2015-12-08 16:13:09 -05:00
2016-01-06 23:11:02 -05:00
Hugo will use the template `robots.txt` according to the following list in descending precedence:
2015-12-08 16:13:09 -05:00
* /layouts/robots.txt
* /themes/`THEME`/layout/robots.txt
An example of a robots.txt layout is:
2016-01-06 23:11:02 -05:00
```http
User-agent: *
2015-12-08 16:13:09 -05:00
2016-01-06 23:11:02 -05:00
{{range .Data.Pages}}
Disallow: {{.RelPermalink}}{{end}}
```
2015-12-08 16:13:09 -05:00
This template disallows and all the pages of the site creating one `Disallow` entry for each one.