Files
davidandClaude Opus 5.5 438192faba Phase 3 part 4: changes approved one at a time, as Gitea pull requests
Proposals (at most 3 waiting) for pages on page one without clicks and
for the audit's title and description issues: the AI writes the title
(without the site's suffix, within the pixel budget) and description
from the live page and its searches. A yes syncs a working copy of the
site's Gitea repository (token as a header only), finds the page's Hugo
content file, sets title and description in its front matter, builds
with Hugo to check the page comes out as proposed, pushes a branch and
opens a pull request; it never merges. Merged changes are checked on
the live site, then compared before and after from Search Console.
Hugo is in the image. Schema 15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:04:01 -07:00

47 lines
2.0 KiB
Go

// Package hugotest makes a small Hugo site in a Git repository, for tests.
package hugotest
import (
"os"
"os/exec"
"path/filepath"
"testing"
)
// Site makes a small Hugo site in a bare repository and returns its
// clone URL. Its titles are "Page title · Site".
func Site(t testing.TB) string {
t.Helper()
dir := t.TempDir()
src := filepath.Join(dir, "src")
files := map[string]string{
"hugo.toml": "baseURL = 'https://site.example/'\ntitle = 'Site'\ndisableKinds = ['taxonomy', 'term', 'RSS', 'sitemap']\n",
"layouts/_default/baseof.html": `<!doctype html><html><head><title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }} · {{ site.Title }}{{ end }}</title><meta name="description" content="{{ .Description }}"></head><body>{{ block "main" . }}{{ end }}</body></html>`,
"layouts/_default/single.html": `{{ define "main" }}<h1>{{ .Title }}</h1>{{ .Content }}{{ end }}`,
"layouts/_default/list.html": `{{ define "main" }}<h1>{{ .Title }}</h1>{{ .Content }}{{ end }}`,
"content/_index.md": "---\ntitle: Home\n---\nWelcome.\n",
"content/pricing.md": "---\ntitle: Pricing\ndescription: |\n Old description\n on two lines\ndraft: false\n---\nOur prices.\n",
"content/blog/first-post/index.md": "+++\ntitle = \"First post\"\n+++\nHello.\n",
"content/about.md": "---\ntitle: About us\nurl: /company/\n---\nWho we are.\n",
}
for name, body := range files {
p := filepath.Join(src, name)
os.MkdirAll(filepath.Dir(p), 0o755)
if err := os.WriteFile(p, []byte(body), 0o644); err != nil {
t.Fatal(err)
}
}
bare := filepath.Join(dir, "site.git")
for _, args := range [][]string{
{"init", "-q", "-b", "main", src},
{"-C", src, "add", "."},
{"-C", src, "-c", "user.name=T", "-c", "user.email=t@example.com", "commit", "-qm", "init"},
{"clone", "-q", "--bare", src, bare},
} {
if out, err := exec.Command("git", args...).CombinedOutput(); err != nil {
t.Fatalf("git %v: %s", args, out)
}
}
return "file://" + bare
}