How to Download a Single Page with Wget and Assets?

When you need to save a web page for offline viewing, downloading just the raw HTML file usually results in a broken layout missing its styles, scripts, and images. This article explains how to configure wget to automatically fetch an HTML page along with only the specific page requisites—like CSS, JavaScript, and images—needed to display that single page correctly. We will cover the exact command-line flags required, how to convert links for local viewing, and how to avoid accidentally downloading the entire website.

The Core Command

To download a single HTML page and all the assets required to render it properly offline, use the following combination of flags:

wget -p -k -E https://example.com/page.html

Breakdown of the Flags

Using wget without any options will only download the isolated HTML file. To get the assets, each flag in the command plays a specific role:

Preventing Crawler Creep

By default, using -p will grab assets even if they are hosted on a different domain (like a font hosted on Google Fonts or a script on a CDN). However, it will not start spidering through the rest of the website’s links.

If you want to be absolutely certain that wget does not follow links to other pages or move up to parent directories, you can add the strict non-recursive flag:

wget -p -k -E -level=0 https://example.com/page.html

Using this command creates a self-contained local folder structure containing the target HTML page and a folder for its assets, allowing you to open the page in any browser completely offline with all visual elements intact.