Wrapper for Hugo static site generator.
The plugin provides a declarative approach for the Hugo binary used to build the static site.
The requested Hugo version is downloaded and cached by Gradle to ensure that your static site is built with the right version of Hugo.
Plugin extension is available to override general configuration (default values provided below).
hugo {
// Hugo version
version = "0.127.0"
// Relative path to sources of Hugo site in Gradle project
sourceDirectory = "site"
// Download URL for Windows ( {0} can be used to replace version )
windowsDownloadUrl = "https://github.com/gohugoio/hugo/releases/download/v{0}/hugo_extended_{0}_windows-amd64.zip"
// Download URL for Linux ( {0} can be used to replace version )
linuxDownloadUrl = "https://github.com/gohugoio/hugo/releases/download/v{0}/hugo_extended_{0}_linux-amd64.tar.gz"
// Download URL for macOS ( {0} can be used to replace version )
macOSDownloadUrl = "https://github.com/gohugoio/hugo/releases/download/v{0}/hugo_extended_{0}_darwin-universal.tar.gz"
// Operating system family (Windows, macOS or Unix)
osFamily = io.github.fstaudt.hugo.OsFamily.CURRENT_SYSTEM // default value derived from system property "os.name"
}
Execute any Hugo command (e.g. new, gen, check ...).
Option command
allows to specify the Hugo command to execute.
It defaults to new site .
.
gradle hugo --command=check
Run server for development of Hugo static site.
Task configuration can be overridden according to your needs (example values provided below).
tasks.hugoServer {
// optional baseUrl to access Hugo static site in browser (defaults to baseUrl configured in config.toml)
baseURL = "http://localhost:1313/documentation/"
// optional additional server arguments (appended to arguments generated from baseUrl)
args = "--buildDrafts --buildExpired"
}
๐ก This task is configurable in build.gradle.kts and should be preferred to hugo
task to serve Hugo static site.
Build Hugo static site for publication.
Task configuration can be overridden according to your needs (default values provided below).
tasks.hugoBuild {
// Output directory for build result
outputDirectory = File("$buildDir/hugo/publish")
// additional path in output directory
publicationPath = ""
// optional additional build arguments (appended to "-d" argument generated from previous properties)
args = ""
}
๐ก This task is cacheable and should be preferred to hugo
task to build Hugo static site.
Download Hugo binary for the current OS (Windows, macOS or Linux).
By default, downloaded version is Hugo extended v0.117.0.
Downloaded version can be configured in Extension configuration.
This task is a dependency of the previous tasks.