Files
kage/docs/content/guides/serving-a-mirror.md
Duc-Tam Nguyen e6afa91e09 Add the clone engine, CLI, tests, CI, and docs
kage renders every page in headless Chrome, snapshots the final
DOM, strips all JavaScript, and localises CSS, images, and fonts
so a site can be browsed offline as a plain folder of files.

The engine is split into small packages:

  urlx      deterministic URL to local-path mapping and scope rules
  sanitize  remove scripts, on* handlers, and javascript: URLs
  asset     rewrite HTML and CSS references, download assets
  browser   headless Chrome pool over the DevTools protocol
  robots    robots.txt matcher
  clone     the orchestrator: a polite resumable breadth-first crawl

The cli package wires a cobra and fang command surface with two
commands, clone and serve. Every pure package has table tests; the
browser and clone packages add Chrome-driven end-to-end tests that
skip when no browser is present or under -short.

CI runs gofmt, vet, build, race tests, golangci-lint, govulncheck,
and a tidy check on Linux and macOS. A goreleaser config fans one
tag out to archives, deb/rpm/apk, a Chromium-bundled GHCR image,
and the package managers. A tago docs site builds to Pages and
Cloudflare.
2026-06-14 18:22:25 +07:00

1.3 KiB

title, description, weight
title description weight
Serving a mirror View a cloned folder the way it would render on a real host, with kage serve. 20

A clone is a plain folder of files, so the simplest way to view it is to open an .html file in your browser. That works for many sites. But some pages use root-relative URLs (/style.css, /img/logo.png), which only resolve correctly when served from the root of a host. kage serve gives you that root.

Serve a clone

kage serve kage-out/example.com
kage serve /…/kage-out/example.com
  open http://127.0.0.1:8800
  press Ctrl-C to stop

Open the printed URL and click around the mirror exactly as you would the live site. Every in-scope link kage rewrote points at another saved page; every asset resolves to its localised copy.

Choose an address

By default kage serves on 127.0.0.1:8800. Change it with --addr:

# A different port
kage serve kage-out/example.com --addr 127.0.0.1:9000

# Reachable from other machines on your network (be deliberate about this)
kage serve kage-out/example.com --addr 0.0.0.0:8800

Serve the current directory

With no argument, kage serve serves the current directory, which is handy from inside an output folder:

cd kage-out/example.com
kage serve