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:
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.
# 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 — 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 — 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 <link rel="alternate"> 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 */}}
{{/* 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 — 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.
---
# 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
hugoand publish directory topublic. Cloudflare Pages will servepublic/llms.txtat/llms.txtfrom their global CDN. See the Cloudflare Pages guide for cache header recommendations. - Vercel — Hugo is detected automatically. Set build command to
hugoand output directory topublic. See the Vercel guide for edge caching options. - GitHub Pages — use a GitHub Actions workflow that runs
hugoand deployspublic/to thegh-pagesbranch. The file will be served athttps://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:
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:
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 for a full spec-compliance check.
Related guides
- How to create llms.txt — templates, checklist, and all stacks.
- Cloudflare Pages guide — deploying Hugo on CF Pages.
- SvelteKit guide — another SSG approach.
- Astro guide — content collection endpoint.
- Best practices — what to include and what to leave out.
- Validator · Generator.