What does `block` mean?

#1

I have the folloing in a tutorial:

      <main id="main">
       {{ block "main" . }}{{ end }}
      </main>

But I can find no reference to block in the documentation

#2

Just searched the docs :slight_smile: and this was the first hit:

1 Like
#3

Where does block fit? Why is it not listed as a function?
And what is the syntax for using block? That page does not say.

#4

This explains pretty well I think:

For instance, n your layouts/_default/baseof.html, you define blocks to say where things should go like block “main”, then replace those with “define”.

#5

I guess I have been spoiled by the good documentation in other projects.

I am very very lost. Really yearning for a technical document that defines all the terms, functions and whatever else Hugo uses in a coherent, logical and consistent way. What I am finding is dismaying.

The search engine is quite good. If I knew what I was doing it would be brilliant.

For examples of how to do it better see: this at MDN or this for Rust

I will persevere for another week or so. I think I can see what I need is in here.

1 Like
#6

@Worik. Once you learn how to use block effectively, please submit a PR to the docs. Looking at the Hugo docs referenced above, it goes through the lookup order, overriddes, example block/base template code, and even includes a video that walks you through usage. I’m eager to see the improvements you’ll provide, since personally I have been using Hugo for far too long to see the content gaps here.

I appreciate the point of reference, but I get the feeling you’re savvy enough to know that comparing the community-generated documentation of a project like Hugo to that of, oh I don’t know, the Mozilla Developer Network’s official HTML5 documentation is, well…silly :crazy_face:

4 Likes