Created
May 22, 2018 15:42
-
-
Save victoriadrake/7d45a8f2ac5cc53743ad34eec8950182 to your computer and use it in GitHub Desktop.
A makefile that regenerates the public/ folder for Hugo sites, optimizes images and prepares the git commit for GitHub Pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL:=/bin/bash | |
BASEDIR=$(CURDIR) | |
OUTPUTDIR=$(BASEDIR)/public | |
optipng = find $(OUTPUTDIR) -name '*.png' -print0 | xargs -0 -P8 -n2 optipng -o5 -strip all -quiet | |
optijpg = find $(OUTPUTDIR) -name '*.jpg' -print0 | xargs -0 -P8 -n2 jpegoptim --strip-all -m30 -q | |
site: | |
@echo "Deleting files from old publication" | |
rm -rf $(OUTPUTDIR)/* | |
@echo "Generating site" | |
hugo | |
@echo "Optimizing images" | |
$(call optijpg) | |
$(call optipng) | |
@echo "Preparing commit" | |
cd $(OUTPUTDIR)/ && git add . && git status && git commit -m "$(m)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use a custom domain with GitHub Pages, ensure that your Hugo site contains the
CNAME
file insideroot/static/
. You can also put yourREADME.md
there.