Lightweight web archiving with SingleFile
Web archiving tools today are mature, and easy enough for anybody to curate their own copy of web pages. The simplest approach is ArchiveWeb.page, a Chrome extension that records the web as you browse, and ReplayWeb.page, a web page that plays your recordings back later. One step up in complexity (which means learning the basics of containerized applications) there are Browsertrix Crawler and Browsertrix. For Browsertrix you don't need a full Kubernetes cluster: k3s on a local computer is enough to run it. All the previous tools are open source and maintained by Webrecorder.
If you want to start, I recommend two nice reads: If you love a website, back it up and DIY Web Archiving.
Sometimes, though, I need something simpler and quicker: a single-shot capture, where the full machinery of WARC/WACZ is not necessary. For these cases I often take screenshots, or save the page as HTML from the browser, to keep a local copy of the content (without any archival compliance).
Lately I started using the SingleFile extension. From its description:
SingleFile is a browser extension that allows you to save an entire web page, including all its resources (e.g., images, stylesheets, fonts, frames, etc.), as a single HTML file with just one click.
The saved page is a standard HTML file. It can be displayed offline in any browser, today or in twenty years, without needing to install any extension. It stays on your computer: no account, no cloud service, and nothing is sent anywhere.
This is my opinionated setup. Here are the settings I change.
File Name → Template
{url-href-digest-sha-1}.{time-ms}.{filename-extension}
{url-href-digest-sha-1}: the SHA-1 hash of the page URL{time-ms}: the save time, in milliseconds since the Unix epoch{filename-extension}: the file extension, depending on the file format (i.e. "html", "u.zip.html", "zip.html", "zip")
This generates opaque filenames, but we will see later why I prefer them.
HTML content
- Save original URLs of embedded resources ☑︎
With this option checked, SingleFile saves the URLs of the resources embedded in the page. The URLs are stored in attributes whose name is prefixed with data-sf-original- and suffixed with the original attribute name (e.g. data-sf-original-src, data-sf-original-href).
Infobar
-
Display an infobar when viewing a saved page ☑︎
-
Template of the infobar content ☑︎
{url-href} ({date-iso}) -
Include the infobar in the saved page ☑︎
-
Keep infobar open ☑︎
Destination
- Save with SingleFile Companion ☑︎
This is the biggest tweak. By default the extension saves an HTML file, and it can only write it to the Downloads folder configured in your browser, not to an arbitrary path on the filesystem. The extension has settings to upload the content to remote services, such as GitHub, WebDAV, S3-compatible storage, Google Drive, or a simple REST API.
I chose another way: SingleFile Companion, a local program that the extension calls via Native Messaging.
To let SingleFile talk to the Companion in Firefox, open the extension settings and, under Permissions and data, enable Exchange messages with programs other than Firefox.
How Native Messaging works: the browser starts the local program, which must be registered with a small JSON manifest giving its path and the extensions allowed to call it. The two sides then talk over stdin/stdout. Each message is a UTF-8 JSON object, preceded by an unsigned 32-bit integer with the message length in bytes, in native byte order. A message from the browser to the program can be up to 4 GB, while a reply from the program back to the browser is limited to 1 MB.
When you save a page, SingleFile sends the Companion a save request. It contains the filename built from the template, the URL of the page, and the whole page as a single HTML string:
{ "method": "save", "pageData": { "filename": "…", "url": "…", "content": "<html>…" } }
I wrote my script in Go, but you can use any language you like. As a reference, see single-file-companion-lite, an implementation in JavaScript.
Why a local script? Because I can add other steps when a page is saved. My script:
-
saves the HTML content in a directory (outside
~/Downloads) -
adds an entry to an index in JSON Lines format, one line per saved page, like this (when the archive grows, the index could be replaced by a local SQLite or DuckDB database):
{"date": "", "url": "", "file": "", "title": ""}For example:
{"date":"2026-11-16T10:27:02+01:00","url":"https://neripozza.it/libro/9788854530492","file":"92376b56467d9bdbfc202f63e52e7f3b127b118f.1794821221379.html","title":"La morte segreta di Josif Giugasvili - Giorgio De Maria"} -
generates a simple HTML page with a table of the saved pages
-
uploads the content to a remote site. I use rsync, but any other transfer tool works.
The index is also why opaque filenames don't bother me: it maps each file back to its URL, date and title.
Other steps I am thinking about: since everything happens locally, I could extract the text and send it to a search engine. Pagefind was my first idea, to keep everything static, but it doesn't support incremental updates of the index: at each save all the HTML files would need to be reindexed, which gets slower as the content grows. A remote index is probably a better fit, and these days my choice would be Luxir.
I could also use a small local LLM to extract, summarize, or categorize the content, but I don't need this right now.
Conclusion
This setup sits somewhere between a bookmarking service and a web archiving service. You can see an example of the result at docuver.se/tmp/singlefile/, with its JSON Lines index. It is only an example: I keep my real archive private, inside my tailnet.