[SOLVED] Index not inheriting baseof in ace templates

Hello, I’ve hit a bit of a block.

Hugo version:

$ hugo env
  Hugo Static Site Generator v0.35-DEV linux/amd64 BuildDate:
  GOOS="linux"
  GOARCH="amd64"
  GOVERSION="go1.9.2"

I got these files:

// layouts/_default/baseof.ace
= doctype html
html lang={{ .Site.Language.Lang }}
  {{- partial "head" . -}}
  body
    {{ block "header" . }}
    header
      h1 {{ .Title }}
    {{ end }}
    {{ block "main" . }}
    / The main content is here
    {{ end }}

// layouts/partials/head.ace
head
  meta charset=utf-8
  meta http-equiv=x-ua-compatible content="ie=edge"
  meta name=viewport content="width=device-width, initial-scale=1"
  title {{- .Title | default .Site.Title -}}

// layout/partials/nav.ace
nav
  p nav

// layouts/index.ace
{{ define "header" }}
p
  this is the header
{{ end }}
{{ partial "nav" . }}
{{ define "main" }}
  p this is main
{{ end }}

But unfortunately the index page being generated looks like this

<html>
  <head></head>
  <body>
    <nav><p>nav</p></nav>
  </body>
</html>

as if it was not inheriting _default/baseof.ace, even through I’ve defined the blocks…

I am doing something wrong?

Is it possible that by “index page” you mean the home page? the name should then be home.ace. If it’s an overview it should be list.ace. Just guessing here, my own home page lies in /page/home.html.

If you “index page” has frontmatter telling it to use “layout: index” it should work the way you structured.

The OP is talking about the layout files. So the naming looks right. The web site home page is rendered from index.html, or in OP’s case index.ace. You then don’t need to set the layout manually in the front-matter.

That said, I haven’t looked in detail at this.

@atea The best way to help you would be if you can share this site on a repo somewhere, with minimal set of files needed to reproduce the problem.

With Ace templates, you need to use the Ace syntax for defining template blocks: = content.

Yes, that was my next step, I inferred wrongly that since {{ partial “something” . }} was equivalent to = include partials/something.ace . then {{ block “something” . }}{{ end }} was going to be equivalent to = yield something.

Anyway, cheers and thanks to all.

We have some logic to determine if “this template needs a base template”, which is some string patterns per template language.

Switched everything to = yield and = content.
Blocks are working, thank you very much for the help.