The build-offline-site.sh
script creates a compressed .tar.gz
file of the site used for offline viewing. This output uses the file://
protocol, meaning that it works directly in a browser without any setup.
Before you start #
- You should fill out the
config/
directory with the appropriate configuration files for each environment if you want to use this script.
Usage #
sh tools/env.sh offline
# Runs the following:
hugo server --config config/offline.yaml --environment offline
How it works #
- For
production
anddevelopment
environments, the script will use the default top-levelhugo.yaml
configuration file. - For all other environments, the script will use the
config/
directory to find the appropriate configuration file.
Default environments #
You can set the environments by updating the ENVIRONMENTS
array in the script.
development
production
offline
enterprise
opensource
Source code #
#!/bin/bash
OUTPUT_NAME="offline-docs"
# USAGE="Usage: sh build-offline-site.sh [draft]"
# This script is for building offline html file:// protocol supported documentation as a .tar.gz for customers that use air-gapped environments.
# It is not intended for live hosted sites.
if [ $1 = "draft" ]; then
echo "Building Hugo site with drafts"
hugo -D --environment development --config config/offline.yaml --minify
else
echo "Building Hugo site without drafts"
hugo --environment development --config config/offline.yaml --minify
fi
tar -czvf $OUTPUT_NAME.tar.gz ./public
# delete the public folder
rm -rf ./public