MakeStaticSite provides native support for generating static sites from the Wayback Machine, resulting in the same kind of output (HTML, CSS and JavaScript) as generated for live sites, making it easy to use and share.
“SO INTERESTING!!!”
Mark Graham
Director, Wayback Machine
Rationale
The Internet Archive provides at web.archive.org an exceedingly popular service for accessing web-specific content, such as an article, that is no longer available on its original website. Furthermore, the service supports browsing (playback of) sites as they were, in some cases going back as far as 1996, which can be a source of considerable historical interest. For example, the first capture of the Museum of the History of Science (MHS) website was on 19 December 1996, available from the Internet Archive at https://web.archive.org/web/19961219005900/http://www.mhs.ox.ac.uk/.
There is, however, no option to ‘download this website’ beyond the browser’s options of saving individual pages. More importantly, for even a long-established service such as the Internet Archive, there is no guarantee it will continue to operate to the same degree. There are various associated risks: funding (to maintain the high performance systems and data centres), legal (particularly around copyright), and security (there may be knock-on effects for security breaches, making services vulnerable indirectly). So, it may well be a race against time for individuals and organisations to preserve sites in such a way that they continue to be available.
This risk is addressed by a relatively small number of archival tools, including MakeStaticSite, that tackle the problem in various ways, as documented in a list of available solutions compiled by the ArchiveTeam. They use the term restoration in their page title, clearly implying a motivation, such as recovery from accidental data loss or the desire to revisit or renew a project. Website (re-)creation, particularly from a static source, naturally falls within the remit of MakeStaticSite — a few steps for this are described below.
MakeStaticSite and Alternatives
There are a few free software solutions that are amenable to incorporation in or linking from MakeStaticSite, though the maintenance varies. Unlike MakeStaticSite, most solutions work directly with Wayback Machine snapshots, not the Web output used by the public.
- From the selection available, integration has been achieved for Hartator’s Wayback Machine Downloader and, more recently, Wayback Machine Downloader JS by WhitelightSEO. Both of these may be described in the context of Wayback Machine as a service. However, as shown in a comparison with MakeStaticSite, the results have been mixed, generally not as complete as expected, even after downloading numerous snapshots. Furthermore, such tools are restricted to the Internet Archive.
- Most of the available solutions generally download a series of snapshots in a specific archive format. There remains the considerable task of reassembling these snapshots as a coherent, navigable and fairly complete website.
- Another approach is Web scraping: like MakeStaticSite, it queries the Wayback Machine through its Playback Web interface, but aims primarily at website restoration, in which pages are processed with minimal modification to navigation beyond removal of the Wayback domain prefix in links. So, when restored to a server on the original domain, they can function as originally intended. But for MakeStaticSite, it is important that it works offline.
As the Playback system carries out the complex assembly work, it makes a lot of sense to piggyback off that. Accordingly, since version 0.30, MakeStaticSite development effort has concentrated on a native approach to the Wayback Machine that queries its Playback service. Furthermore, the particular challenges facing Wget around URL formats (using the -np flag) can be circumvented by an iterative process of parsing pages, determining lists of further URLs to fetch, and then postprocessing to gather the downloads in a sensible fashion. Such URLs generally contain both the original URL and the timestamp of a capture. We can filter what further to download based on the timestamp without needing to understand in detail how it was assembled. Mirroring such content with Wget should also enable the retrieved files to work offline as well as online.
MakeStaticSite provides support for fetching web content from any site running a Wayback Machine, not just web.archive.org, and can crawl pages from arbitrary number of timestamps, albeit subject to resource limitations.
Basic Usage
A static site from the Wayback Machine can be generated through a one-line command, but the configuration options should be reviewed before its first use.
Configuration
For native handling of Wayback Machine content, in constants.sh, ensure that the client switch is set to ‘no’:
wayback_cli=no
Also consider how much you need to archive, bearing in mind that the process is generally a lot slower via a Wayback Machine than for mirroring sites directly. Consider imposing quotas. For example, to limit the number of requests sent by Wget to the Wayback Machine server, set the following:
quota=requests
quota_requests_wayback=requests_cap
Having found the required Wayback URL, as described above, usage is the same as with any other URL. For a shortcut using default settings, you can run the following:
$ ./setup.sh -u https://web.archive.org/web/19961219005900/http://www.mhs.ox.ac.uk/
MakeStaticSite will proceed to check the response header from the site and report if it is serving mementos, which is assumed to indicate a Wayback Machine.
The mirror is generated as with other URLs, with a few additional options:
- reverting to the domain of the captured site instead of retaining the Wayback Machine host name. (This is not yet reflected in the zip file name.)
- removal of the (Playback) code inserted by the Wayback Machine
- removal of comments inserted by the Wayback Machine.
To illustrate the kind of output that MakeStaticSite generates compare the Wayback URL: https://web.archive.org/web/19961219005900/http://www.mhs.ox.ac.uk/ with the corresponding MakeStaticSite output.
Date Ranges
Date ranges limit the output to content that was fetched by the Wayback Machine between those dates (by ‘date‘ we mean date and time).
This can be specified using the same commands with just a slight variation, replacing a single timestamp with two timestamps separated by a semicolon. Hence:
$ ./setup.sh -u https://web.archive.org/web/19961219005900-19970412232929/http://www.mhs.ox.ac.uk/sphaera/issue1/text.htm
The initial run on MakeStaticSite will be carried out on the from date (i.e. 19961219005900 above). As this uses the ‘page requisites’ option of Wget, it may fetch content from other timestamps, but subsequent runs will constrain content fetches to the range.
Archive Directory Naming
With Wayback URLs, there are options to specify precisely the name format of the mirror archive directory (stored in the variable, mirror_archive_dir). It is possible to record the primary snapshot generated by the Wayback Machine, as specified in url, the timestamp of MakeStaticSite’s capture, along with the Wayback host domain and the target primary domain.
These are determined by two constants: wayback_sitename_hosts and wayback_sitename_timestamps. The options selected will likely depend on usage scenarios.
The host options are:
- [default] wayback_sitename_hosts=wayback (or
empty string) sets the stem based on the Wayback host
name
E.g., web.archive.org - wayback_sitename_hosts=primary sets the stem
based on the target primary domain
E.g., www.example.org - wayback_sitename_hosts=both sets the stem
based on the Wayback host name
E.g., web.archive.org-www.example.org
The timestamp options specify timestamps according to the Wayback URL entered (which can include date ranges) and the run of MakeStaticSite. Note that MakeStaticSite timestamps may be distinguished by their use of the underscore character.
They are tied to the host options above. Hence:
- [default]
wayback_sitename_timestamps=wayback (or empty
string) appends the ‘from'[-‘to’] Wayback
timestamp[s]
E.g., web.archive.org19970412232929
web.archive.org-www.mhs.ox.ac.uk19970412232929
I.e., Wayback Machine archive of www.mhs.ox.ac.uk, with primary snapshot on 12 April 1997 at 23:29:29, captured by MakeStaticSite from web.archive.org (no timestamp). - wayback_sitename_timestamps=mss appends the
MakeStaticSite timestamp
E.g., web.archive.org20240912_160154
I.e., Wayback Machine archive captured by MakeStaticSite from web.archive.org on 12 September 2024 at 16:01:54 (local time). - wayback_sitename_hosts=both appends the
‘from'[-‘to’] Wayback timestamp[s] to the Wayback host
portion and the MakeStaticSite timestamp to the target
domain portion.
E.g., web.archive.org20240912_160154-www.mhs.ox.ac.uk19970412232929
I.e., Wayback Machine archive of www.mhs.ox.ac.uk, with primary snapshot on 12 April 1997 at 23:29:29, captured by MakeStaticSite from web.archive.org on 12 September 2024 at 16:01:54 (local time).
These options will likely prove more useful when carrying out more captures and repeat captures.
Tailoring Wayback Output
MakeStaticSite retrieves the versions of pages that are delivered to users when they browse the Wayback Machine, which are enhanced for compatibility with modern browsers and to sustain onward navigation. Among the measures it introduces is the modification of link URLs to ensure a fixed Wayback domain prefix and to insert JavaScript for archive navigation along with comments stating copyright and archival data.
The net result of these measures is that any mirror generated by MakeStaticSite needs adjustments to work independently of the Wayback Machine. Accordingly, the output can be tailored to a range of needs: for restoration, there are clean-up options so that it is ready to redeploy online; for archival, snapshot data from the original crawls can be retained.
Tidying Pages
There are several options that determine the extent to which output from the Wayback Machine is cleaned, which may be broadly divided into two: enabling independent navigation and the removal of superfluous Wayback-specific code.
For navigation, there are two options:
- wayback_links_relative_rewrite: when set to yes, this ensures the most thorough rewriting of relative links.
- wayback_code_clean: when set to yes, deletes the JavaScript Playback code inserted by the Wayback Machine in the head of the document.
For the code tidy, there are also two options.
- wayback_comments_clean: when set to yes, deletes HTML comments inserted by Wayback Machine in the footer.
- wayback_relative_links_clean: when set to original, restore the original URL links in web pages, removing Wayback prefixes in these URLs.
As the comments include some important archival data, the clean operation only happens after that data has been extracted, discussed next.
Archival
MakeStaticSite supports formal digital preservation through WARC files, but as a light-touch alternative, archival information can be embedded in the static output.
Making Wayback timestamps visible
For a given original URL, the Wayback Machine uses a top frame to provide calendar navigation across different timestamped versions. At the foot of the page, inserted as a HTML comment, are some details of the web crawl used to fetch the page at that time. A sample:
<!--
FILE ARCHIVED ON 12:32:14 Feb 18, 2007 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 15:05:22 Nov 26, 2026.
JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)).
-->
MakeStaticSite has no need for the JavaScript, but provides an option to record the date and time as they are useful for archival purposes. To enable this, first set wayback_comments_showtimestamp=yes.
Several options determine how to isolate the code inserted by the Wayback Machine and can be tweaked if this subsequently changes.
wayback_timestamp_prefix="FILE ARCHIVED ON " # string that prefixes the timestamp
wayback_timestamp_suffix=" AND" # string that postfixes the timestamp
wayback_timestamp_insert_after="$body_tag_re" # Where to insert the Wayback timestamp on a web page.
Finally, a bit of CSS styling for the output:
wayback_comments_timestamp_div="<div id=\"overlay\" style=\"color:white; font-size:12px; text-align:left; padding-left:5px; position: fixed; top: 0; left: 0; width: 300px; height: 20px; background-color: rgba(0, 0, 0, 0.5); z-index: 1000\">"
This creates a transparent overlay, located top right to report the date and time of the page snapshot.
Website Restoration
Whilst it is not generally possible to completely recover a website from the Wayback Machine to a server in its original configuration, the mirroring process might replicate much of its behaviour and it may suffice for practical purposes, particularly archival, to carry out such a restoration.
To restore a website to its original domain, noting these limitations, options should be set as follows:
- wayback_links_relative_rewrite=yes
- wayback_code_clean=yes
- wayback_comments_clean=yes
- wayback_relative_links_clean=wayback
In addition, anchors that have not been localised can be reverted to their original links by setting:
- wayback_prefixes_remove=yes
The effectiveness of this may be hit and miss; it may improve navigation, but also yield HTTP 404 errors that have to be addressed individually.
N.B. (Security) The ownership of the original host domain should be checked. If the ownership has lapsed or been transferred, then this setting should not be used or, at least ensure that the host domain is changed to one where the ownership is trusted.
Splitting a mirror into multiple runs
(Please note that this is putative and not yet tested.)
For larger sites, it may be possible to split the task of site mirroring by directory, with separate runs for each directory based on Wget’s --no-parent option. This will output a site to the original path (so will need to drill down to access it) and generate a sitemap that reflects it. This task can then be distributed to a group of users, each user apportioned a particular run (or runs). On completion, the outputs can be merged, with some care.
As a prerequisite, change the default settings in constants.sh to ensure that MakeStaticSite doesn’t move the output to the root directory:
mss_cut_dirs=no
Each run will require its own configuration file, with the assigned URL. A straightforward arrangement is to select top-level directories, such as:
https://example.com/directory1/
https://example.com/directory2/
...
https://example.com/directoryn/
For these directories, the default or existing configuration settings may usually be left as they are.
The remaining content is the root directory. Here, the crawl should be limited (or else why divvy up the task?) to run Wget non-recursively. For this, remove or limit the recursive option from Wget, by changing the wget_mirror_options constant. For example, to allow a crawl of one further step, set:
wget_mirror_options=(--recursive --timestamping --level=1 --no-remove-listing)
The value of level will depend on how the navigation is set up, with the aim of aim reaching every page in the root directory (the --page-requisites option in wget_core_options) should ensure that supporting assets are fetched automatically).
Also, for the root directory, there is probably no need to run phase 3, so set it to not carry out further crawling:
wget_extra_urls_depth=0
Site re-assembly
An outline of a re-assembly process:
- Create a working directory for the re-assembly.
- Within that create a directory sources, and extract/copy the individual mirror outputs inside, one directory for each output.
- In the root directory, create a sitemap.xml as a merge of the individual sitemap.xml files in the respective output directories; copy the robots.txt file from the original root directory.
- Choose a fresh directory, where the site is to be re-assembled
- Copy over root directory output followed by the other directory outputs. It is likely that you will encounter duplication.
- Copy over the merged sitemap.xml file.
- Tidy up.
All being well, this will yield a fully reassembled and navigable static site.