Can't evaluate field Content in type - in index.html of theme

Hi there i am currently trying to create a page using hugo (surprise).
However, in the /layouts/index.html of my theme is the following:

{{ partial "header.html" . }}
<body>
    <div class="container">
        {{ partial "navbar.html"  . }}
        <div class="content">
            <h2>{{.Title}}</h2>
            {{.Content}}
        </div>
    </div>
{{ partial "footer.html" . }}
</body>

I created two test pages in the main directory, in /content using html files (index.html and test.html).

My issue is:

[...]
WARN: 2016/09/08 17:45:36 site.go:2004: "" is rendered empty
ERROR: 2016/09/08 17:45:36 general.go:212: Error while rendering homepage: template: theme/index.html:7:14: executing "theme/index.html" at <.Content>: can't evaluate field Content in type *hugolib.Node
0 draft content
0 future content
0 expired content
2 pages created
0 non-page files copied
0 paginator pages created
0 tags created
0 categories created
in 19 ms
[...]

The rendered page is cutted after .Title

I am not sure if i am just doing it wron or if it is an valid issue.
Sorry if i just doing it wrong.

Check out this comment on the Github issues page. That method works for me.

Yes, that works, but I’m not sure that is what thread starter wants.

/layouts/index.html, aka the home page, is usually used to list pages (title, summary). There are plenty of examples in the themes floating around of how to do this.

Hello again,

there are two types of templates in Hugo: pages and nodes. pages are used to render the content files, therefore you can access a variable called .Content.

Every other page is a node, like the homepage, which will rendered with the index.html theme. Those pages aren’t associated with any content and don’t have the same-named variable. What would it contain?

I suggest to follow @sethm’s linked comment. Currently, it’s a common practice to range over all pages and filter them. Now you’re working with pages and you’ve access to the content variable.

Oh, hi, looks like my thread was accepted by an admin.^^

Thanks for the quick replys here.

but I’m not sure that is what thread starter wants.

I wanna create a “simple” html page with several subpages.
Maybe blog functionallity will also come in the future.

While i waited to get my thread accepted here, i wrote with someone who uses Hugo some time now.

My index.html contains

{{ range where  .Data.Pages "Title" "index"}}
{{ partial "header.html" . }}
<body>
    <div class="container">
        {{ partial "navbar.html"  . }}
        <div class="content">
            {{ .Content }}
        </div>
    </div>
    {{ partial "footer.html" . }}
</body>
{{end}}

now. Also i learned that content like

+++
title = "index"
+++

Is important. I ignored the new command since i though it is just like a touch.

Now i will check out the single.html file for the other pages.

Thanks for all the feedback, i hope i will do steps forward now. :heart:


Edit: subpages are working just wonderful now, thanks again!