{{ define "main" }}
{{ .Content }}
{{/* Define a section to pull recent posts from. For Hugo 0.20 this will default to the section with the most number of pages. */}} {{ $mainSections := .Site.Params.mainSections | default (slice "post") }} {{/* Create a variable with that section to use in multiple places. */}} {{ $section := where .Site.RegularPages "Section" "in" $mainSections }} {{/* Check to see if the section is defined for ranging through it */}} {{ if $section }} {{/* Derive the section name by creating a string from the initial section definition */}} {{ $section_name := printf "%s" (delimit ($mainSections) " ") }}
{{/* Use $section_name to get the section title. Use "with" to only show it if it exists */}} {{ with .Site.GetPage "section" $section_name }}

Recent {{ .Title }}

{{ end }}
{{/* Range through the first three items of the section */}} {{ range (first 3 $section) }}
{{ partial "summary-with-image.html" . }}
{{ end }}

More

{{/* Now, range through the next four after the initial 3 items. Nest the requirements, "after" then "first" on the outside */}} {{ range (first 4 (after 3 $section)) }}

{{ .Title }}

{{ end }} {{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}} {{ with .Site.GetPage "section" $section_name }} All {{.Title }} {{ end }}
{{ end }} {{ end }}