Mirroring a Web Page with wget
How to mirror a static web page with a single wget command, walking through what the --mirror, --convert-links, --adjust-extension, --page-requisites, and --no-parent flags each do.
Machine-translated from the Chinese original.

Sometimes we need to save a web page, whether to browse offline or to archive / back it up.
For a dynamic page, you may need to dig into where its data comes from; but for a simple static page, a single wget command will do the job.
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://example.com/something.html
What each flag does
--mirror
Downloads recursively.
--convert-links
Rewrites links (including links inside
css).wgetdownloads all of a page’s resources, images,js,css, fonts, and so on, to local disk.--convert-linksrewrites the original absolute references into relative ones, so the page is less likely to break when you browse it locally.
--adjust-extension
Fixes the extensions of
htmlandcssfiles based on theContent-Typeheader (note: it does not fixjsextensions). For example, say a page originally references acssfile namedFunUI.css?15552165. Regardless of whether such a filename is even valid under NTFS naming rules, when loaded locally the browser won’t treat it as a stylesheet, since its extension isn’t.css. With--adjust-extensionadded,wgetrenames the file to[email protected], so the browser can recognize it correctly.
--page-requisites
Downloads
css, images, and other content needed for the page to display correctly.
--no-parent
With this flag,
wgetwon’t ascend to parent directories while recursing. Since we only want to save the current page, this flag is needed.
The command above can also be written as
wget -mkEpnp https://example.com/something.html
where np is short for --no-parent.
Did you know
wget has a single-file build for Windows, which is great for carrying around on a USB drive; here it is too: wget.exe.