Skip to content
Regis Philibert edited this page Sep 28, 2021 · 7 revisions

HUGE Config

HUGE takes its configuration settings through stand alone files of either yaml, toml or json language located in the _huge/config/ directory at the root of the Hugo project.

Settings are optional but highly recommanded. List of available files are as follow:

  • styles
  • scripts
  • fonts
  • media
  • seo

Configuration Functions

TL;DR: Use function's returned value in HUGE's config. slides: carousel/GetHomeSlides()

A script!

Slide data will be dynamically generated by a Hugo returning partial.

# _huge/config/scripts.yaml
scripts:
- path: js/carousel/index.js
  params:
    slides: carousel/GetHomeSlides()
{{/* layouts/partials/carousel/GetHomeSlides.html 
{{ $slides := slice }}
{{ with site.Home.Params.slides }}
  {{ $slides = . }}
{{ end }}
{{ return $slides }}

Media settings!

imgix domain will be dynamically generated by a Hugo returning partial which tests the environment.

# _huge/config/media.yaml
imgix: 
  domain: functions/GetImgixDomain()
{{/* layouts/partials/functions/GetImgixDomain.html */}}
{{ $domain := "staging.imgix.net" }}
{{ if partial "huge/env/IsProduction" . }}
  {{ $domain = "live.imgix.net" }}
{{ end }}
{{ return $domain }}

Configuration functions are HUGE!

User can use the value returned by a function to populate any key from the HUGE Config files!

To do so, one must use a string starting with the path to the function relative to the partials directory and append ()

key: path_to_partial()
  • carousel/GetHomeSlides() will be replaced by the value returned by layouts/partials/carousel/GetHomeSlides.html
  • my-config-funcs/imgix_domain() will be replaced by the value returned by layouts/partials/my-config-funcs/imgix_domain.html

A few things of note:

  1. Extension is required only if not HTML as Hugo partial API always falls back on .html when extension is omitted.
  2. Currently . other than extension delimiters are not accepted in configuration functions filenames: my-config-funcs/imgix.domain() will fail the build.
  3. If no partial matching the path is found, HUGE will break the build with a message pointing to the not found partial.

For a partial located at /layouts/partials/logic/GetThings.html

filepath ok/no reference ok/no
/layouts/partials/logic/GetThings.html logic/GetThings()
/layouts/partials/logic/GetThings.html logic/GetThings.html()
/layouts/partials/logic/GetThings.html layouts/logic/GetThings() 🚫
/layouts/partials/logic/GetThings.dev logic/GetThings() 🚫
/layouts/partials/logic/GetThings.dev logic/GetThings.dev()
/layouts/partials/logic/imgix.media.html 🚫 logic/imgix.media() 🚫
Clone this wiki locally