Hugo Integration Guide

Embed a live Linux CLI terminal in Hugo

Hugo powers high-traffic Go, Kubernetes, and CNCF project documentation via themes like Docsy and PaperMod. Adding one tiny shortcode under layouts/shortcodes/ lets Markdown authors drop live CLI terminals into any page with theme auto-matching.

1. Add KilnVM to Hugo

layouts/shortcodes/kilnvm.html (reusable Hugo shortcode)
{{- if not (.Page.Scratch.Get "kilnvm_loaded") -}}
  {{- .Page.Scratch.Set "kilnvm_loaded" true -}}
  <script src="https://kilnvm.dev/kilnvm-embed.js" defer></script>
{{- end -}}
<div
  data-kilnvm-project="{{ .Get "project" | default "proj_your_project_id" }}"
  data-kilnvm-theme="{{ .Get "theme" | default "auto" }}"
  {{- with .Get "id" }} data-kilnvm-id="{{ . }}"{{ end -}}
  {{- with .Get "cmd" }} data-kilnvm-cmd="{{ . }}"{{ end -}}
  {{- with .Get "height" }} data-kilnvm-height="{{ . }}"{{ end -}}
></div>

2. Seed Files, Run Buttons & Production Tips

content/docs/quickstart.md (calling the shortcode in Markdown)
Run the CLI right in your browser:

{{< kilnvm project="proj_your_project_id" cmd="mycli --help" theme="auto" height="400" >}}

<!-- Or add clickable Run buttons targeting data-kilnvm-id="qs" -->
<button type="button" data-kilnvm-run="mycli version" data-kilnvm-target="qs">
  Check Version
</button>
  • Using .Page.Scratch ensures kilnvm-embed.js loads once per rendered page even if a tutorial embeds multiple terminal cards.
  • Set unsafe = true under [markup.goldmark.renderer] in hugo.toml if you write inline HTML <button data-kilnvm-run> elements directly in Markdown.
  • Add both your Hugo preview URL (e.g. Cloudflare Pages / Netlify deploy previews) and production docs origin under Allowed Docs Origins.

3. Try a Live Sandbox Right Now

Click Launch Terminal below to boot a real non-root Linux microVM directly in the page.

Frequently Asked Questions

Does this shortcode work with Hugo Docsy and Hugo Book themes?

Yes. Drop layouts/shortcodes/kilnvm.html in your site root and it overrides cleanly across Docsy, Book, Blowfish, and PaperMod with no theme fork.

Are Go, Rust, and Linux binaries supported unmodified?

Yes. Each embed runs a real linux/amd64 container built from your Dockerfile or release image, so compiled Go/Rust CLIs work identically to local installs.

Ready in 5 minutes

Ship live CLI sandboxes inside your docs.

Start free with 300 sessions per month, isolated linux/amd64 microVMs, and zero credit card required.