I installed and customised a theme that creates a single page out of multiple .md files. When creating a page, this theme takes into account any file in content
, including those in sub-folders. I would like to create pages only from direct children, especially for the front page (the one at localhost:1313
).
/content/
child1
child2
section1/
grandchild1
I want to build a page using only child1
and child2
, excluding grandchild1
I tried to set up an index.md
file at the root of content
, but this prevents me from accessing other pages.
I’m trying to find, if possible, a good where
function usage to create this condition. Keep in mind that I’m a newbie and I’m not a Go programmer.
In terms of code, the following line includes all pages :
{{ range $index, $element := .Data.Pages}}
I would like to do something like :
{{ range $index, $element := where .InSection(.Data.Pages)}}
Unfortunately, I can’t get this to work.
Here is the full code :
<section id="services">
<!-- Page Content -->
{{ range $index, $element := .Data.Pages}}
{{ if modBool $index 2 }}
<div class="content-section-a">
{{ else }}
<div class="content-section-b">
{{ end }}
<div class="container">
<div class="row">
<div>
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">{{ .Title }}</h2>
{{ .Content }}
</div>
</div>
</div>
<!-- /.container -->
</div>
{{ end }}
</section>
Hugo env :
Hugo Static Site Generator v0.34 linux/amd64 BuildDate: 2018-01-22T12:06:40Z
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.9.2"