Skip to content

Custom domain with GitHub Pages

Anthony Fok edited this page Jun 11, 2021 · 1 revision

Regarding the use of custom domain, and including subdirectories from other repos under the same domain:

  1. Use a GitHub workflow file.
  2. Build main site as usual.
  3. Checkout a pre-built site from other repo, e.g. the gh-pages branch of OpenDRR/documentation
  4. Copy the above (w/o .git directory) into _site/documentation
  5. Deploy with peaceiris/actions-gh-pages@v3 as before, with the cname setting pointing to the desired custom domain name, which ensures the file CNAME is generated for the final site. GitHub relies on this file for custom domain name to work. Without this, each deploy would clear the custom domain setting!

Demo at:

GitHub Actions log:

Note: This is definitely not the only way to do it, and probably not the best way either, but it is a proof-of-concept with minimal changes to existing repos.

Clone this wiki locally