hugo/content/en/functions/complement.md
Bjørn Erik Pedersen b9bd35d72e Squashed 'docs/' content from commit fdea5430f
git-subtree-dir: docs
git-subtree-split: fdea5430f89dfd849d39212abdf5ace0a4763e5a
2019-10-21 10:22:28 +02:00

894 B

title description date categories menu keywords signature hugoversion aliases
complement `collections.Complement` (alias `complement`) gives the elements of a collection that are not in any of the others. 2018-11-07
functions
docs
parent
functions
collections
intersect
union
COLLECTION | complement COLLECTION [COLLECTION]...
0.51

Example:

{{ $pages := .Site.RegularPages | first 50 }}
{{ $news := where $pages "Type" "news" | first 5 }}
{{ $blog := where $pages "Type" "blog" | first 5 }}
{{ $other := $pages | complement $news $blog | first 10 }}

The above is an imaginary use case for the home page where you want to display different page listings in sections/boxes on different places on the page: 5 from news, 5 from the blog and then 10 of the pages not shown in the other listings, to complement them.