As you know that you can use gh-pages branch to create document site for each repo, there is also a way that you can build a site from your organization and deploy your
site to github.com. Furthermore, you can use Hugo to create a static website and deploy it anywhere you want.
The following will describe the process with an example site www.networknt.com which is deployed to netlify.com
Once you are happy with the result, kill the server and remove the generated public folder under docs.
rm -rf public
Create a submodule
git submodule add -b master [email protected]:networknt/networknt.github.io.git public
This creates a git submodule. Now when you run the hugo command to build your site to public, the created public directory will have a different remote origin (i.e. hosted
GitHub repository). You can automate some of these steps with the following script.
This will build the site and put rendered site into public folder.
You’re almost done. You can also add a deploy.sh script to automate the preceding steps for you. You can also make it executable with chmod +x deploy.sh.
The following are the contents of the deploy.sh script:
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
# Build the project.
hugo # if using a theme, replace with `hugo -t <YOURTHEME>`
# Go To Public folder
# Add changes to git.
git add .
# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
git commit -m "$msg"
# Push source and build repos.
git push origin master
# Come Back up to the Project Root
Use a custom domain
If you’d like to use a custom domain for your GitHub Pages site, create a file static/CNAME. Your custom domain name should be the only contents inside CNAME. Since it’s inside static, the published site will contain the CNAME file at the root of the published site, which is a requirements of GitHub Pages.