Is it possible to exclude the terms "London" and "Berlin" from being displayed when calling {{.Params.locations}} and only showing "New York" and "Boston"?
EDIT
More info on what I’m trying to accomplish. I have the following in index.html:
If I understand correctly you want to concatenate two taxonomy terms into a custom range. Never tried that… But see scratch at the Docs also there is a list of useful articles about Hugo functions (scratch has its own) in this thread.
This is the best I could find because range where needs an object property, and ranging on your params, the string you want to exclude is not inside a property. range where is out but with does the trick:
{{ $exclude := slice "London" "Berlin" }}
{{ range .Params.locations }}
{{ $location := . }}
{{ with not (in $exclude . ) }}
<li>
<a href="{{ $location | urlize }}" title="{{ $location }}">{{ $location }}</a>
</li>
{{ end }}
{{ end }}
Now that you’ve figured it out, would you let us know why you are doing this? It helps others understand why folks do things.
For instance, if you have two terms you don’t ever want to show, why use a taxonomy for it? Why not use a different parameter, to designate those pieces?
First come to mind: Dealing with a large amount of “automaticly” imported markdown files with plenty of useless metadata/taxonomy left there by an obscure framework.
Just saw your post now, so sorry for the delayed response.
@regis is right. I’ve got some unused metadata that I don’t want to display but it will hopefully become useful in the future so I don’t want to delete it.
As a disclaimer, most of the things i do with Hugo are perhaps unconventional and not considered best practice. This stuff is not really my jam, I’m learning as I go along. My goal is to solve problems, and how they get solved is not important. Over time, however, my code does get better
Hugo is still in early development, we all have to use hacks pending a better understanding of the framework!
As long we follow the evolution of Hugo enough to replace those hacks by future features, we’ll be fine I think