This is going to be the first drupaloid content. I didn't want to pay for hosting to have my own Drupal blog and you probably don't want it too.
- Setup a GitHub repo.
- Setup a local php/mysql server for your site with a working drush. I recommend the Composer Template for Drupal projects.
- With your Drupal site running on your local environment, enable Tome Module.
- In your settings.php you are going to setup tome default directory as 'docs' in your repository root:
$settings['tome_static_directory'] = '../docs';
- Run the drush command: drush tome:static --uri=http://yourdomain.com
Now you have a 'docs' directory in your repository root with a complete static copy of your drupal site.
IMPORTANT: This is the folder Github Pages is going to serve as your Website, so, you don't want to change this folder name.
- Go the repository settings in Github and make the Github Pages source your 'docs' folder:
I have created a little deploy script to correct the CNAME removal problem that you get if you clear the 'docs' folder, and, to automatically generate and deploy the static copy.
- Create a file in your repository root ./scripts/publish_github
- Give permission to it using command chmod +x ./scripts/publish_github
- Open the file in your favorite editor:
#!/bin/sh # Clear the 'docs' folder. rm -rf docs/* # Generate the static site using tome drush command. vendor/drush/drush/drush tome:static --uri=https://drupaloid.dev # Recreate the CNAME file that Github Pages use to identify your site custom domain. echo "drupaloid.dev" > docs/CNAME # Add the whole 'docs' folder for a new commit. git add docs git commit -m "static site deploy" # Push to the repo. git push