DESIGN SYSTEM

  • Principles
  • Components
  • Documentation
FUNCTIONS

complement

collections.Complement (alias complement) gives the elements of a collection that are not in any of the others.

Syntax

COLLECTION | complement COLLECTION [COLLECTION]...

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.

See Also

  • symdiff
  • intersect
  • group
  • append
  • Foundation styles (FS)
  • Content text (CT)
  • Buttons and links (BL)
  • Form elements (FE)
  • Icons (IC)
  • Miscellaneous (MS)
“complement” was last updated: January 29, 2019: A little bit of naming reorganisation (8fb631a0)
Improve this page
By the Hugo Authors
Hugo Logo
  • File an Issue
  • Get Help
  • Discuss Source Code
  • @GoHugoIO
  • @spf13
  • @bepsays

 
  Hugo Sponsors
Logo for Forestry.io
Logo for Linode
Logo for eSolia
 

The Hugo logos are copyright © Steve Francia 2013–2019.

The Hugo Gopher is based on an original work by Renée French.

  • Principles
  • Components
  • Documentation
  • Foundation styles (FS)
  • Content text (CT)
  • Buttons and links (BL)
  • Form elements (FE)
  • Icons (IC)
  • Miscellaneous (MS)