Hugo themes typically exist as standalone GitHub repositories that users can use for their projects-—either as a Git Submodule or Hugo Module.
To enable clean separation of theme logic while still providing real-world examples of how to use the theme, create an exampleSite directory. In this directory, set up a demo site that utilizes your theme and includes content that documents and showcases the theme’s features. This site serves as an example of this.
Users can unpack the exampleSite directory to experiment with a demo site or use it as a starting point for their own site using your theme.
How to locally test your theme #
You don’t want to reference your own theme as a dependency when testing it, so you can build the site using the top-level theme directory as the source.
- Open the terminal.
- Run the command
cd exampleSiteto navigate into theexampleSitedirectory. - Run the command
hugo server --theme ../..to build the site using the top-level theme directory as the source.
How to deploy a demo site #
Netlify #
Create a
netlify.tomlfile in the root of your theme repo (not in theexampleSitedirectory).Copy and paste the following into the
netlify.tomlfile.toml[build] publish = "exampleSite/public" command = "cd exampleSite && hugo --theme ../.." [build.environment] HUGO_VERSION = "0.146.0" HUGO_THEME = "milodocs"Update the
HUGO_THEMEvariable to the name of your theme; it must match the value found in the top-leveltheme.tomlfile.
AWS Amplify #
TBD