gohugoio/hugo · error

must provide an URL and optionally an options map

Error message

must provide an URL and optionally an options map

What it means

Thrown by resources.GetRemote when the variadic args length is not 1 or 2. GetRemote expects exactly one URL string plus an optional options map. Zero args or more than two args triggers this.

Solutions

  1. Pass exactly one URL and an optional options map: {{ resources.GetRemote $url }} or {{ resources.GetRemote $url $opts }}.
  2. Ensure the URL variable is set before calling.
  3. Remove any extra arguments beyond the options map.

Example fix

// before
{{ resources.GetRemote }}
// after
{{ resources.GetRemote $url (dict "method" "get") }}
Defensive patterns

Strategy: validation

Validate before calling

{{ with $url }}{{ resources.GetRemote . }}{{ end }}

Prevention

When it happens

Trigger: Calling {{ resources.GetRemote }} with no URL, or passing three or more arguments. Also when the URL argument is omitted because a variable was unset and not piped.

Common situations: Forgetting to pass the URL; passing extra positional arguments beyond the options map; piping nil into the call.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/8186449286300458. Report an issue: GitHub.

Appendix: source

Thrown at tpl/resources/resources.go:116

	r, err := ns.createClient.Get(filenamestr)
	if err != nil {
		panic(err)
	}

	return r
}

// GetRemote gets the URL (via HTTP(s)) in the first argument in args and creates Resource object that can be used for
// further transformations.
//
// A second argument may be provided with an option map.
//
// Note: This method does not return any error as a second return value,
// for any error situations the error can be checked in .Err.
func (ns *Namespace) GetRemote(args ...any) (resource.Resource, error) {
	get := func(args ...any) (resource.Resource, error) {
		if len(args) < 1 || len(args) > 2 {
			return nil, errors.New("must provide an URL and optionally an options map")
		}

		urlstr, err := cast.ToStringE(args[0])
		if err != nil {
			return nil, err
		}

		var options map[string]any

		if len(args) > 1 {
			options, err = hmaps.ToStringMapE(args[1])
			if err != nil {
				return nil, err
			}
		}

		return ns.createClient.FromRemote(urlstr, options)
	}

View on GitHub (pinned to 52c9bd7908)