Hosted Drupal + Netlify

This guide will describe how you can use traditional Drupal hosting, Tome Static, and Netlify to have a normal content editing experience while still running static html on your public-facing site.

First, you'll need to host a Drupal 8 site somewhere. For my testing, I've used Pantheon, which provides a free-tier and the ability to lock down environments, which is important for keeping people away from your content editing domain.

  1. Assuming you have a basic Drupal 8 installation, run this command from where your site's "composer.json" file lives: "composer require drupal/tome drupal/tome_netlify".

  2. Edit your site "settings.php" file and set the "tome_static_directory" setting to a writeable directory on your hosting provider. For Pantheon, I add this block of code:
     

    if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
      $settings['tome_static_directory'] = 'sites/default/files/private/tome_static';
    }
    

     

  3. Commit the changes and push to your remote repository if you're using version control.

  4. Create a Netlify account at https://app.netlify.com/signup

  5. Login to  your Drupal site as an administrator. Ensure you are using the HTTPS URL of your Drupal site, as Netlify pushes will fail when using HTTP.

  6. Enable Tome Static and Tome Netlify at /admin/modules. You're enabling Tome Static and not Tome since you don't need any of the "store your content in Git" features that Tome Sync provides.

  7. Visit /admin/config/tome/static/generate and generate your first static site.

  8. Visit /admin/config/tome/static/download and download the static build. Extract the generated .tar.gz file.

  9. Visit https://app.netlify.com/account/sites and drag+drop your static build folder to the dropzone at the bottom of the screen. This will create a new Netlify site that isn't tracked in Git.

  10. Click into your new site in the Netlify UI, then click "Settings". Copy your site-specific "API ID" from there.

  11. Visit https://app.netlify.com/account/applications and generate a new personal access token. Copy your token as it can not be retrieved after viewing it the first time.

  12. Visit /admin/config/services/tome_netlify/settings and enter your token and site ID, then save the form.

  13. Visit /admin/config/tome/netlify/send and click Deploy.

  14. Wait a few minutes after a deploy is complete for Netlify to pick up the new build, then preview it using the link provided. Builds sent to Netlify only include files that have changed since the last build, which should make them super-duper fast.

  15. When satisfied with the deploy, publish the draft on Netlify at "Deploys" when viewing your site in the UI.

  16. You're done!

While this guide may seem daunting, I think this hosting setup is the most reasonable for Drupal users who don't want to change the way content editors use Drupal, but still want to run a static site on the frontend.