Create Hugo Website

Pre-requisites

  • Hugo installed on your machine docs here
  • Git installed on your machine docs here

Create a new Hugo website

  • Create a new Hugo website : hugo new site <website-name>
  • Go to the website directory : cd <website-name>
  • Initialize a new git repository : git init
  • I am using the Relearn theme.
  • By followong the docs here you customize & setup your website locally.
  • Once you are done with the setup, you can build the website using hugo command.
  • This will generate a public folder in your website directory.
  • This folder contains all the static files for your website and is ready to be deployed.

Git setup

  • Create 2 seperate repositories for the website (public folder) and the other source code.

  • Add the public folder to the .gitignore file in the source code repository.

  • Add the source code repository as a submodule in the public folder.

    • cd public
    • git init && git add . && git commit -m "Initial commit"
    • git submodule add <source-code-repo-url> <path-to-source-code-repo>
  • Push the public folder to a remote repository (I am using GitLab)