/ llmtxt.info

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.

static/llms.txt — directory structure
# 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
# 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
# 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 — simple
{{/* 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
{{/* 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
---
# 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 for cache header recommendations.
  • Vercel — Hugo is detected automatically. Set build command to hugo and output directory to public. See the Vercel guide 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
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
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

Sources