How to Install and Use monolith in Linux to Save Complete Webpages as Single Offline HTML Files

Archiving web pages for offline documentation, compliance audits, academic research, or disaster recovery typically presents a challenge. Saving a webpage through a standard browser menu splits the document into a raw HTML skeleton and a separate directory containing hundreds of external CSS stylesheets, JavaScript files, images, and web fonts. If any linked asset is moved or deleted, the saved page breaks. The monolith CLI utility, written in Rust, solves this by scraping a target URL and bundling all images, stylesheets, scripts, and fonts directly into a single, self-contained HTML document with zero external asset dependencies.

Why Use monolith Instead of Standard Web Scrapers?

Unlike traditional scrapers such as wget or curl, which preserve directory trees of assets, monolith embeds everything inline:

  • Data URI Encoding: Converts JPEG, PNG, SVG, WebP, and favicon graphics into inline base64 data URIs directly within the HTML markup.
  • Inline Stylesheets and Web Fonts: Downloads external CSS rules and web font files (WOFF/WOFF2), embedding them inside <style> tags.
  • JavaScript Isolation Options: Allows you to preserve client-side JavaScript or strip executable scripts completely to prevent tracking and security vulnerabilities.
  • Security and Portability: Produces a single portable file that can be opened in any web browser, emailed as an attachment, or stored in offline document repositories without broken links.

Step 1: Install monolith on Linux

Depending on your Linux distribution, you can install monolith using precompiled binaries, Cargo, or native package repositories:

Method A: Install via Official Precompiled Binary (Recommended)

# Download the latest Linux release from GitHub
curl -sSLf "https://github.com/Y2Z/monolith/releases/latest/download/monolith-gnu-linux-x86_64" -o /tmp/monolith

# Move binary to executable path and grant permissions
sudo install -m 755 /tmp/monolith /usr/local/bin/monolith
rm /tmp/monolith

Method B: Install via Cargo (Rust Package Manager)

cargo install monolith

Method C: Install on Arch Linux

sudo pacman -S monolith

Verify the Installation

monolith --version

Step 2: Save a Webpage into a Single HTML File

To archive any public URL into a unified HTML document, invoke monolith followed by the target web address and the -o (output) flag:

monolith https://docs.kernel.org -o linux_kernel_docs.html

The utility resolves the DOM tree, downloads all dependent visual media, converts assets to inline base64 streams, and outputs a single .html file. You can disconnect your internet connection and open the file in Chrome or Firefox; all styling, fonts, and images render identically to the live website.

Step 3: Strip JavaScript for Security and Static Archiving

By default, monolith preserves JavaScript. However, when archiving documentation or news articles, active scripts can trigger intrusive paywall popups, analytics trackers, or dynamic re-renders. Use the -s (silent/strip scripts) flag to generate a purely static snapshot:

# Archive a technical tutorial with JavaScript stripped
monolith -s https://example.com/guide -o guide_static.html

The resulting document preserves full CSS formatting and visual diagrams while eliminating tracking scripts and unwanted dynamic behavior.

Step 4: Exclude External CSS or Images to Minimise File Size

If you only require text content and page typography without heavy high-resolution photography:

# Exclude embedded images to create a lightweight document
monolith -I https://en.wikipedia.org/wiki/Linux -o linux_wiki_no_images.html

# Exclude external fonts
monolith -F https://example.com -o example_no_fonts.html

Step 5: Supply Custom User-Agent and Authentication Credentials

Web servers frequently block generic automated user agents or require specialized cookies to render authenticated internal dashboards:

Custom User-Agent Spoofing

monolith -u "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36" https://news.ycombinator.com -o hn.html

Pass Session Cookies for Gated Content

To archive internal documentation behind an enterprise login, pass session cookies directly from your browser session:

monolith -b "session_token=abcdef123456; auth=true" https://internal.dev/wiki/architecture -o architecture_audit.html

Automating Webpage Archiving via Shell Pipelines

Because monolith accepts input via standard input (stdin), you can pipe a list of URLs from a text file to archive an entire documentation portal overnight:

while IFS= read -r url; do
    filename=$(echo "$url" | sed -e 's/[^A-Za-z0-9._-]/_/g').html
    echo "Archiving $url into $filename..."
    monolith -s "$url" -o "$filename"
done < urls.txt

Verifying File Integrity and Portability

To verify that an archived document contains no unresolved external references, grep the output HTML file for external HTTP resources: grep -i 'src="http' linux_kernel_docs.html. If the query returns zero matches, the document is completely self-contained and ready for offline air-gapped deployment.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.