Merge commit '87de22d7464e239c775fbd48ebce1665d5b1e80d'

This commit is contained in:
Bjørn Erik Pedersen
2023-07-29 11:17:28 +02:00
177 changed files with 1623 additions and 1556 deletions

View File

@@ -1,18 +1,18 @@
---
title: Robots.txt File
linktitle: Robots.txt
title: Robots.txt file
linkTitle: Robots.txt
description: Hugo can generate a customized robots.txt in the same way as any other template.
categories: [templates]
keywords: [robots,search engines]
menu:
docs:
parent: templates
weight: 165
weight: 165
weight: 230
weight: 230
aliases: [/extras/robots-txt/]
---
To generate a robots.txt file from a template, change the [site configuration][config]:
To generate a robots.txt file from a template, change the [site configuration]:
{{< code-toggle file="hugo" >}}
enableRobotsTXT = true
@@ -26,14 +26,14 @@ User-agent: *
Search engines that honor the Robots Exclusion Protocol will interpret this as permission to crawl everything on the site.
## Robots.txt Template Lookup Order
## robots.txt template lookup order
You may overwrite the internal template with a custom template. Hugo selects the template using this lookup order:
1. `/layouts/robots.txt`
2. `/themes/<THEME>/layouts/robots.txt`
## Robots.txt Template Example
## robots.txt template example
{{< code file="layouts/robots.txt" >}}
User-agent: *
@@ -47,14 +47,13 @@ This template creates a robots.txt file with a `Disallow` directive for each pag
{{% note %}}
To create a robots.txt file without using a template:
1. Set `enableRobotsTXT` to `false` in the [site configuration][config].
1. Set `enableRobotsTXT` to `false` in the [site configuration].
2. Create a robots.txt file in the `static` directory.
Remember that Hugo copies everything in the [static directory][static] to the root of `publishDir` (typically `public`) when you build your site.
[config]: /getting-started/configuration/
[static]: /getting-started/directory-structure/
{{% /note %}}
[config]: /getting-started/configuration/
[site configuration]: /getting-started/configuration/
[internal]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/robots.txt