Skip to content
Regis Philibert edited this page Aug 27, 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 optinal but highly recommaned. List of available files are as follow:

  • styles
  • scripts
  • fonts
  • media
  • seo

Configuration Functions

TL;DR:

A script!

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

Media settings!

# _huge/config/media.yaml
imgix: 
  disable: my-config-funcs/imgix_disable()
  domain: my-config-funcs/imgix_domain()
{{/* layouts/partials/my-config-funcs/imgix_disable.html */}}
{{ return site.IsServer }}
{{/* layouts/partials/my-config-funcs/imgix_domain.html */}}
{{ $domain := "staging.imgix.net" }}
{{ if partial "huge/env/Is" "production" }}
  {{ $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()
  • my-config-funcs/imgix_disable() will be replaced by the value returned by layouts/partials/my-config-funcs/imgix_disable.html
  • carousel/GetHomeSlides() will be replaced by the value returned by layouts/partials/carousel/GetHomeSlides.html
  • logic/ParsePosts.dev() will be replaced by the value returned by layouts/partials/logic/ParsePosts.dev

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.disable() 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