Guest User

Untitled

a guest
Oct 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. There is more than one way to do this, depending on the number of sections. For example, if you have three sections (One, Two, Three) and only want to disinclude one in the list page, you could do something like this (assuming you want the most recent first, otherwise you can omit `.ByPublishDate.Reverse`):
  2.  
  3. ~~~
  4. <ul class="section-one-and-two-pages">
  5. {{ range .Site.Pages.ByPublishDate.Reverse }}
  6. {{ if or (eq .Section "One") (eq .Section "Two")}}
  7. <li>{{.Title}}</li>
  8. {{end}}
  9. {{ end }}
  10. </ul>
  11. ~~~
  12.  
  13. Or if you just want to omit section Three and want to show sections One and Two, it could be DRYer with the following. This will also be easier if your plan is to, say, create 10 sections and only leave one out since you won't have to modify your code at all on the "overview" page:
  14.  
  15. ~~~
  16. <ul class="section-one-and-two-pages-by-just-omitting-three">
  17. {{ range where .Site.Pages.ByPublishDate.Reverse "Section" "!=" "Three" }}
  18. <li>{{.Title}}</li>
  19. {{ end }}
  20. </ul>
  21. ~~~
Add Comment
Please, Sign In to add comment