Override Hugo variable

Hi everyone,
Is it possible to override a hugo variable ?
In my case i would like to use a json variable here named selfName like the type hugo variable.

I don’t understand what you mean. Are you talking about in front matter or a global variable?

In the front matter, i would like to have the same behavior with my variable than the hugo variable type.

Hmmm. Can you give me some more context and tell me what you’re trying to accomplish? You can’t necessarily “override” the Hugo type, but maybe we can still get your desired end result…

If I understand correct you would like to set front matter with selfName: someType in order to override the type template loading with a custom template? If so you could try using partials and conditions

{{ $selfName := $.Params.selfName }}

{{ if $selfName }}
    {{ partials $selfName . }} // Loads the partial named "someType.html"
{{ else }}
   {{ partials "default.html" . }}
{{ end }}

The partial someType.html would include your header body footer etc to render a complete page

1 Like

Ok, thx :slight_smile:

1 Like