diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a1e690392c..d444a7029e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,18 @@ Relevant coding style guidelines are the Go Code Review Comments and the Formatt In order to contribute to Layer5 docs, please follow the fork-and-pull request workflow described [here](./CONTRIBUTING-gitflow.md). + +# LLM-friendly page output + +Every rendered documentation page exposes a **View as markdown** link. The link +targets the page's `llms.txt` output, which contains the page title, description, +and rendered content without the site's navigation, sidebar, footer, or styling. + +This has been achieved by using the Hugo Module for llms.txt and llms-full.txt. +## References +- [Module post](https://discourse.gohugo.io/t/hugo-module-for-llms-txt-and-llms-full-txt/56990) +- [GitHub](https://github.com/gethugothemes/hugo-modules/tree/master/llms-txt) + ## Prerequisites Make sure you have the following prerequisites installed on your operating system before you start contributing: diff --git a/go.mod b/go.mod index c276ccb0a25..cb1e1902f2f 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/layer5io/docs go 1.26.4 require ( + github.com/gethugothemes/hugo-modules/llms-txt v0.0.0-20260701054856-10b1d2cdc11a // indirect github.com/google/docsy v0.14.3 // indirect github.com/google/docsy/dependencies v0.7.2 // indirect ) diff --git a/go.sum b/go.sum index 91e513190fb..5bfa5c1966d 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/FortAwesome/Font-Awesome v0.0.0-20230327165841-0698449d50f2/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo= github.com/FortAwesome/Font-Awesome v0.0.0-20241216213156-af620534bfc3/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo= +github.com/gethugothemes/hugo-modules/llms-txt v0.0.0-20260701054856-10b1d2cdc11a h1:i0Vn9qzsJIHkbEn5SvI1FdvOb2nM4W5HYaHcC7n5QCc= +github.com/gethugothemes/hugo-modules/llms-txt v0.0.0-20260701054856-10b1d2cdc11a/go.mod h1:NbshvI0tQlvBA7ZZrP8kik0M6g3b0Gr0ftEP3NV+9os= github.com/google/docsy v0.14.3 h1:4uFgPWTPj4NT79IboVkXGi49LLQadLVfU4WNOfD/s74= github.com/google/docsy v0.14.3/go.mod h1:1Fj1W1O3esZh7IBQ8XAYtxtg10udBXuGI89+LUQc1AU= github.com/google/docsy/dependencies v0.7.2 h1:+t5ufoADQAj4XneFphz4A+UU0ICAxmNaRHVWtMYXPSI= diff --git a/hugo.toml b/hugo.toml index a697e6188bb..933477e7541 100644 --- a/hugo.toml +++ b/hugo.toml @@ -99,10 +99,11 @@ description = "Product Documentation" # Comment out if you don't want the "print entire section" link enabled. [outputs] - home = ["HTML", "RSS", "SITEMAP"] - section = ["HTML", "RSS"] - taxonomy = ["HTML", "RSS"] - term = ["HTML", "RSS"] + home = ["HTML", "RSS", "SITEMAP", "llms", "llmsfull", "md"] + page = ["HTML", "llms", "llmsfull", "md"] + section = ["HTML", "RSS", "llms", "llmsfull", "md"] + taxonomy = ["HTML", "RSS", "llms", "llmsfull", "md"] + term = ["HTML", "RSS", "llms", "llmsfull", "md"] [sitemap] changefreq = "daily" @@ -354,3 +355,10 @@ enable = false [[module.mounts]] source = "charts" target = "static/charts" + + [[module.imports]] + path = "github.com/gethugothemes/hugo-modules/llms-txt" + +[params.llms] + generate_llms_txt = true + generate_llms_full_txt = true diff --git a/layouts/_default/list.llms.txt b/layouts/_default/list.llms.txt new file mode 100644 index 00000000000..a8d46de4088 --- /dev/null +++ b/layouts/_default/list.llms.txt @@ -0,0 +1,5 @@ +# {{ .Title }} + +{{ with .Description }}{{ . }} + +{{ end }}{{ .RawContent }} \ No newline at end of file diff --git a/layouts/_default/list.llmsfull.txt b/layouts/_default/list.llmsfull.txt new file mode 100644 index 00000000000..7138d201f99 --- /dev/null +++ b/layouts/_default/list.llmsfull.txt @@ -0,0 +1 @@ +{{ with .RawContent }}{{ . }}{{ else }}{{ .RawContent }}{{ end }} \ No newline at end of file diff --git a/layouts/_default/single.llms.txt b/layouts/_default/single.llms.txt new file mode 100644 index 00000000000..a8d46de4088 --- /dev/null +++ b/layouts/_default/single.llms.txt @@ -0,0 +1,5 @@ +# {{ .Title }} + +{{ with .Description }}{{ . }} + +{{ end }}{{ .RawContent }} \ No newline at end of file diff --git a/layouts/_default/single.llmsfull.txt b/layouts/_default/single.llmsfull.txt new file mode 100644 index 00000000000..7138d201f99 --- /dev/null +++ b/layouts/_default/single.llmsfull.txt @@ -0,0 +1 @@ +{{ with .RawContent }}{{ . }}{{ else }}{{ .RawContent }}{{ end }} \ No newline at end of file diff --git a/layouts/partials/page-llms-link.html b/layouts/partials/page-llms-link.html new file mode 100644 index 00000000000..0477a98e957 --- /dev/null +++ b/layouts/partials/page-llms-link.html @@ -0,0 +1,5 @@ +{{ with .OutputFormats.Get "md" -}} + + View as Markdown + +{{ end -}} \ No newline at end of file diff --git a/layouts/partials/page-meta-links.html b/layouts/partials/page-meta-links.html index 1ca390641df..1b614b3900e 100644 --- a/layouts/partials/page-meta-links.html +++ b/layouts/partials/page-meta-links.html @@ -6,6 +6,7 @@ {{ $gh_project_repo := ($.Param "github_project_repo") -}} {{ $gh_branch := (default "main" ($.Param "github_branch")) -}}
+{{ partial "page-llms-link.html" . }} {{ if $gh_url -}} {{ warnf "Warning: use of `github_url` is deprecated. For details see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}} {{ T "post_edit_this" }} diff --git a/layouts/video/video.html b/layouts/video/video.html index 4782ee210ed..aefd69b13e6 100644 --- a/layouts/video/video.html +++ b/layouts/video/video.html @@ -11,6 +11,7 @@

{{ .Title }}

+ {{ partial "page-llms-link.html" . }}

{{ .Description }}

{{ if .Params.featured_video }}