Creating a Static Drupal Site with Tome

Submitted by Drupalguy on Mon, 11/02/2020 - 17:36

Creating a Static Drupal Site with Tome

Case:

We have a site on pantheon and we use lando for local development

We will created a lando instance and use tome to transition to a static html site.
I will also create a separate lando instance to not interfere with the live site/development just because.
And will create a gitlab repository and host the site on gitlab since it will be pure html

Build Local:

- clone site
- edit .lando.yml and edit name to make it unique
     (cannot use the pantheon name because it is already in use by your original site)
     (this site will not be used to maintain the pantheon site)
- run 'lando start'
- run 'lando pull' to pull down the database and files from live
- test to make sure you can access your lando site
- Install the Tome module
     'composer require drupal/tome'
- Enable the Tome module
     Use the UI or with drush 'drush en tome_static -y'
- If you wish to use the command line Tome requires Drush 9 or above (optional)
     (NOTE!!! if you install this and will be pushing this code back up to pantheon make sure you .gitignore vendor/drush & vendor/bin/drush directories as Pantheon does not play nice with multiple versions of drush)
     'composer require drush/drush:^9'
- create directories for Tome to generate content in the web root directory.
     (I suggest putting them in their own directory) ex.
     tome/files
     tome/content
     tome/html
     tome/repo
- edit settings.php and add these settings
     $settings['tome_files_directory'] = 'tome/files';
     $settings['tome_content_directory'] = 'tome/content';
     $settings['tome_static_directory'] = 'tome/html';
- Setup is complete.  

Generate static site:

     using drush:
        drush tome:static --uri=http://mysite.com
           (Where "mysite.com" is the domain of your production site)
     user interface:     
        login as a user with the "use tome static" permission
        submit the form at "/admin/config/tome/static/generate"

Prepare Local Gitlab Repository:

- create a bash script file to copy the files from the 'html' folder to the 'repo' folder.
     #!/bin/bash
     \cp -Rf html/* repo/
- run the bash script 
     or run the command '\cp -Rf html/* repo/' if you don't want to use the script

Gitlab:

- Go to Projects page and create new project
- Set the visibility level to public   
- Create project 
- on the repository page follow the instructions to 'Push an existing folder'
      (on page https://gitlab.com/<gitlab-acct>/<project-name>)
      run the git commands from the 'tome/repo' folder
- setup domain
     go to settings > pages
     select 'New Domain'
     enter domain
        leave certificate enabled
     select 'Create New Domain'
     follow instructions to verify your ownership of the domain
        after the domain is verified, save your changes
- setup gitlab to serve the pages for the website
        (https://docs.gitlab.com/ee/user/project/pages/getting_started/pages_ci_cd_template.html)
     go to project page and select 'Set up CI/CD'
     go to 'Apply a template' and choose 'HTML'
     save and commit the '.gitlab-ci.yml' file

Site will be live on gitlab after the pipeline completes.