diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html
index fe208398c5..bff5a32b77 100644
--- a/layouts/shortcodes/children.html
+++ b/layouts/shortcodes/children.html
@@ -4,13 +4,20 @@
{{ $withDescription := .Get "description" | default false }}
{{ $sortTerm := .Get "sort" | default "Weight" }}
-
{{ .Scratch.Set "pages" .Page.Pages }}
- {{ if .Page.Sections}}
- {{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
- {{end}}
- {{ $pages := (.Scratch.Get "pages") }}
+
+ {{if .Page.IsHome}}
+
+ {{ $rootPage := where .Page.Pages "Dir" "" }}
+ {{ .Scratch.Set "pages" (.Page.Sections | union $rootPage)}}
+ {{else}}
+ {{ if .Page.Sections}}
+ {{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
+ {{end}}
+ {{end}}
+
+ {{ $pages := (.Scratch.Get "pages") }}
{{if eq $sortTerm "Weight"}}
{{template "childs" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
@@ -33,64 +40,61 @@
{{ range .menu }}
{{ if and .Params.hidden (not $.showhidden) }}
{{else}}
-
+ {{if not .IsHome}}
+ {{if hasPrefix $.style "h"}}
+ {{$num := sub ( int (trim $.style "h") ) 1 }}
+ {{$numn := add $num $.count }}
-{{if hasPrefix $.style "h"}}
- {{$num := sub ( int (trim $.style "h") ) 1 }}
- {{$numn := add $num $.count }}
+ {{(printf "" $numn)|safeHTML}}
+ {{ .Title }}
+ {{(printf "" $numn)|safeHTML}}
-{{(printf "" $numn)|safeHTML}}
-{{ .Title }}
-{{(printf "" $numn)|safeHTML}}
-
-{{else}}
-{{(printf "<%s>" $.style)|safeHTML}}
-{{ .Title }}
-{{(printf "%s>" $.style)|safeHTML}}
-{{end}}
-
-
-
-
-
- {{if $.description}}
- {{if .Description}}
-{{.Description}}
{{else}}
-{{.Summary}}
+ {{(printf "<%s>" $.style)|safeHTML}}
+ {{ .Title }}
+ {{(printf "%s>" $.style)|safeHTML}}
+ {{end}}
+
+ {{if $.description}}
+ {{if .Description}}
+ {{.Description}}
+ {{else}}
+ {{.Summary}}
+ {{end}}
{{end}}
{{end}}
-
-
-
{{ if lt $.count $.depth}}
-{{if eq $.style "li"}}
-
-{{end}}
- {{ .Scratch.Set "pages" .Pages }}
- {{ if .Sections}}
- {{ .Scratch.Set "pages" (.Pages | union .Sections) }}
- {{end}}
- {{ $pages := (.Scratch.Get "pages") }}
- {{if eq $.sortTerm "Weight"}}
- {{template "childs" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
- {{else if eq $.sortTerm "Name"}}
- {{template "childs" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
- {{else if eq $.sortTerm "PublishDate"}}
- {{template "childs" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
- {{else if eq $.sortTerm "Date"}}
- {{template "childs" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
- {{else if eq $.sortTerm "Length"}}
- {{template "childs" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
- {{else}}
- {{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
- {{end}}
-{{if eq $.style "li"}}
-
-{{end}}
+ {{if eq $.style "li"}}
+
+ {{end}}
+
+ {{ if .Sections}}
+ {{ .Scratch.Set "pages" (.Pages | union .Sections) }}
+ {{else}}
+ {{ .Scratch.Set "pages" .Pages }}
+ {{end}}
+
+ {{ $pages := (.Scratch.Get "pages") }}
+
+ {{if eq $.sortTerm "Weight"}}
+ {{template "childs" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
+ {{else if eq $.sortTerm "Name"}}
+ {{template "childs" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
+ {{else if eq $.sortTerm "PublishDate"}}
+ {{template "childs" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
+ {{else if eq $.sortTerm "Date"}}
+ {{template "childs" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
+ {{else if eq $.sortTerm "Length"}}
+ {{template "childs" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
+ {{else}}
+ {{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
+ {{end}}
+
+ {{if eq $.style "li"}}
+
+ {{end}}
{{end}}
-
{{end}}
{{end}}
{{end}}
\ No newline at end of file