Check for a page's title

I would want to render a title’s surrounding tags, only if a page’s title is non-empty/existing. How do I check for that?

For a start, you could add a conditional like the following.

{{ if .Title }}
  <!-- Put the tags here -->
{{ end }}

As said from the templating introduction:

Go Templates treat the following values as false :

  • false (boolean)
  • 0 (integer)
  • any zero-length array, slice, map, or string

I feel embarrassed :slight_smile: Thanks!
I had tried it with with and isset …

No problem! We all have those moments. :grinning: