12

I wonder if there is an existing module that can help in the subject. I am not looking for a caching module (like Boost or Varnish), but a way to export my whole site (or only certain pages) into static. The idea is that I want my web server will be a very simple and light and will only serve static files (html/css/js) - no database on production, no php engine will be installed on server. All the Drupal engine will be on another server, export will be done each time adding/editing/changing a node or view, and a new set of html files will be created in a directory structure. These files will later on be copied to the production site that will serve always and only static files, no .htaccess that will check requests if file exist etc.

Is there a module for that, or a workaround that this can be achieved with Drupal?

Thanks

6 Answers 6

5

I use HTTrack for this, also there's this article on drupal.org: Creating a static archive of a Drupal site.

0
3

There is a new Drupal 7 module providing this functionality is Static Generator

Static Generator:

The static module generates a complete copy of your website in html form including all js, css, images and other assets. This can then be transferred to run the website from a simple web server without PHP, MySQL or memcache.

Benefits:

  • Performance: No PHP, Mysql, etc on public facing site. Everything is a static file so it is served very quickly.
  • Security: The static version of the site does not have a database, user accounts or any other form of user interaction (except 3rd party integrations) so it is much more secure.
  • Reliability: Most of the usual failure points are gone. PHP, MySQL, memcache, varnish, etc are no longer part of the static site.

Limitations:

Due to the fact that there is no database or PHP behind the website, any functionality that requires it can't be used. 3rd part libraries can fill in most of the needed functionality.

Some of the parts that can't be used are:

  • No views filters
  • Drupal comments
  • Drupal search.
  • No drupal forms.
  • No context (not the module) - meaning you can't change the page contents based on the user unless you do it in javascript.
  • No ajax callbacks (except pre-generated GET requests)

Pagers DO work as long as they are passed through hook_preprocess_pager.

2

GNU wget is a WWW client that can download the pages of your site and store them locally. Use the -r option to download pages recursively (i. e. follow links to pages on the same site found on the current page). It can also convert absolute URLs to relative one (using the -k option).

0
2

A lot has changed since this question was asked.

Widely used non-Drupal solution: Gatsby

Gatsby has become a popular static site generator and it works with Drupal.

Gatsby has docs on Drupal and there is a Gatsby module to make it easier to use Drupal as the data source for Gatsby. Drupal hosts like PlatformSH even support Gatsby + Drupal together now.

I only want to use Drupal

The Tome module can generate a static site from within Drupal. See the module page for documentation.

2
  • 1
    I disagree with "Most popular: Gatsby". Gatsby is an option, but not an easy one. Tome has more installations, is simple and straightforward to use and host (does not need NodeJs or "Not-your-server as a service").
    – Hudri
    Commented Jun 18 at 10:28
  • @Hudri Those are good points. I actually use Tome myself as well. But what I meant by "most popular" is that Gatsby has its own community which is quite large (55K stars on Github as of writing). I'll update my answer to make that clear. Commented Jun 18 at 15:17
1

You can use the Wget Static - Generate HTML and Save To FTP / Webdav module, which does exactly what you want. In fact, I have also deployed the same architecture as you have discussed just above.

You can select the content for static HTML generation, which can also be bypassed using query parameters. Then, the second part comes where you perform static HTML generation using wget. This module covers almost all the options necessary for static data generation.

It also allows to save the generated HTML markup on a FTP or Webdav server, and it supports two-factor authentication too.

The Wget Static - Generate HTML and Save To FTP / Webdav module does not have releases for Drupal 8 or higher. Its last stable release has been created on January 11, 2016; no further development has been done after that date.

0

I'm looking for something similar. I've searched the modules and found the following options, but haven't looked into either of them yet:

We want to use S3 or another static file serving CDN service for our site, so it's possible something more like the following will be helpful:

Another thought is that it may be possible to leverage a caching framework like boost and add something to push the files to production as it caches them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.