<!-- Generated from llms-txt-hugo/index.html. The canonical document is the HTML page. -->

- [ Home ](/) 
/
- [ How to create ](/how-to-create/) 
/
- Hugo guide            
# llms.txt for Hugo

Two approaches: a static file in static/ (zero config, works everywhere), or a custom output format that generates llms.txt automatically from your content at build time.

Last updated: April 22, 2026

ℹ Which approach to use?

If your  llms.txt  content is stable and you update it manually, use the
static file , zero config, zero risk. If you want it to stay in sync with your
content automatically on every  hugo  build, use the
custom output format .

## Option 1: static file (recommended)

Hugo copies everything in the `static/` directory directly to the `public/` build output. Place your `llms.txt`
there and it will be served at `/llms.txt` on any hosting platform, no Hugo config changes
needed.
static/llms.txt, directory structure   
Copy

```
# Hugo, zero-config static approach
#
# Place your file at: static/llms.txt
# Hugo copies everything in static/ directly to the public/ output directory.
# Your file will be served at /llms.txt on any host.
#
# Project structure:
# your-hugo-site/
# ├── static/
# │   └── llms.txt   ← add this
# ├── content/
# ├── layouts/
# └── hugo.toml
#
# No config changes needed. Run "hugo" and it appears in public/llms.txt.

```

After running `hugo`, you'll find `public/llms.txt`
in your build output. Deploy `public/` to Cloudflare Pages, Vercel, GitHub Pages, or any
static host.

## Option 2: custom output format

Hugo's output format system lets you generate any file type from your content using Go
templates. Define a new `LLMSTXT` format in your config, then create the template, Hugo
builds `public/llms.txt`
automatically on every `hugo` run.

### Step 1, add the output format to your config
hugo.toml   
Copy

```
# hugo.toml, define the llmstxt custom output format

[outputs]
home = ["HTML", "RSS", "LLMSTXT"]

[outputFormats.LLMSTXT]
mediaType = "text/plain"
baseName = "llms"
isPlainText = true
notAlternative = true

```

Using YAML? Same config:
hugo.yaml   
Copy

```
# hugo.yaml, same config in YAML

outputs:
home:
- HTML
- RSS
- LLMSTXT

outputFormats:
LLMSTXT:
mediaType: text/plain
baseName: llms
isPlainText: true
notAlternative: true

```

The key settings are `mediaType = "text/plain"` (so Hugo writes a plain text file), `baseName = "llms"` (produces
`llms.txt`), and `notAlternative = true` (suppresses an unwanted ` ` tag in your HTML).

## Writing the template

Create the template at `layouts/index.llmstxt.txt`. Hugo uses the *home* template
for the root-level output. Here's a simple version that lists all regular pages:
layouts/index.llmstxt.txt, simple   
Copy

```
{{/* layouts/index.llmstxt.txt */}}
{{/* Hugo home template for the llmstxt output format */}}
# {{ .Site.Title }}

> {{ .Site.Params.description }}

{{ with .Site.Params.llmstxtContext }}{{ . }}

{{ end -}}
## Pages

{{ range .Site.RegularPages -}}
- [{{ .Title }}]({{ .Permalink }}): {{ with .Description }}{{ . }}{{ else }}{{ .Summary | plainify | truncate 120 }}{{ end }}
{{ end }}

```

For a site with multiple content sections (blog, docs, tutorials), organize by section:
layouts/index.llmstxt.txt, by section   
Copy

```
{{/* layouts/index.llmstxt.txt, organized by section */}}
# {{ .Site.Title }}

> {{ .Site.Params.description }}

{{ range .Site.Sections -}}
## {{ .Title }}

{{ range .Pages -}}
- [{{ .Title }}]({{ .Permalink }}): {{ with .Description }}{{ . }}{{ else }}{{ .Summary | plainify | truncate 100 }}{{ end }}
{{ end }}
{{ end -}}

## Optional

- [Homepage]({{ .Site.BaseURL }}): site entry point.

```

✓ Use description frontmatter

Hugo's  .Summary  is auto-extracted from the first paragraph of each page, it's often too
long or too generic for a good llms.txt entry. Add a  description  field to your frontmatter
for a precise, hand-crafted summary:
content/docs/getting-started.md   
Copy

```
---
# content/docs/getting-started.md
title: "Getting started"
description: "Install the CLI, run your first command, and deploy in under 5 minutes."
draft: false
---

Your content here...

```

## Deployment

- **Cloudflare Pages**, set build command to `hugo`
and publish directory to `public`. Cloudflare Pages will serve
`public/llms.txt` at `/llms.txt` from their global CDN. See the [Cloudflare Pages guide](/llms-txt-cloudflare/) for cache header recommendations. 
- **Vercel**, Hugo is detected automatically. Set build command to `hugo` and output directory to `public`. See the
[Vercel guide](/llms-txt-vercel/) for edge caching options. 
- **GitHub Pages**, use a GitHub Actions workflow that runs
`hugo` and deploys `public/` to the
`gh-pages` branch. The file will be served at
`https://your-org.github.io/llms.txt`. 
- **Any static host**, deploy the `public/` directory. The file will be at
the root and served correctly.   
## Verify

First check locally:
Local verification   
Copy

```
hugo
ls public/llms.txt          # should exist
cat public/llms.txt          # check content
https_proxy="" hugo server
curl http://localhost:1313/llms.txt
```

After deploying:
Production verification   
Copy

```
curl -I https://yoursite.com/llms.txt
# Expected:
# HTTP/2 200
# content-type: text/plain; charset=utf-8
```

Then paste the URL into the [validator](/validator/) for a full spec-compliance check.

## Related guides

- [How to create llms.txt](/how-to-create/), templates, checklist, and all stacks. 
- [Cloudflare Pages guide](/llms-txt-cloudflare/), deploying Hugo on CF Pages. 
- [SvelteKit guide](/llms-txt-sveltekit/), another SSG approach. 
- [Astro guide](/llms-txt-astro/), content collection endpoint. 
- [Best practices](/best-practices/), what to include and what to leave out. 
- [Validator](/validator/) · [Generator](/generator/).        
## Sources

- [ llmstxt.org, official spec ](https://llmstxt.org/)
- [ Hugo docs, custom output formats ](https://gohugo.io/configuration/output-formats/)
- [ Hugo docs, template lookup order ](https://gohugo.io/templates/lookup-order/)           
On this page

- [ Option 1: static file (recommended) ](#static)
- [ Option 2: custom output format ](#output-format)
- [ Writing the template ](#template)
- [ Deployment ](#deployment)
- [ Verify ](#verify)
