Hide title for certain pages

Hi, I am new to HUGO and would love to hide/remove the titles for all my posts. In my head.html, I have the following lines:

  {{ if .IsHome }}
    {{ $title = .Site.Title }}
  {{ end }}

Is there a similar command to check whether the section or parent page is “posts” and then set the $title parameter to “”? Thank you very much

Try:

  {{ if .IsHome }}
    {{ $title = .Site.Title }}
     {{ else if in .RelPermalink "/posts/" }}
        {{ $title = "" }}
  {{ end }}

and similar constructs.

Also have a look at Logic - Conditionals

Thank you very much for your quick response. Unfortunately, the title is still there. My head.html now looks as follows:

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  {{ hugo.Generator }}
  {{ $summary := trim (.Summary | plainify | htmlUnescape) "\n\r"
    | default .Title }}
  <meta name="description" content="{{ $summary }}">
  <link rel="stylesheet" href="{{ "css/bootstrap.min.css" | absURL }}">
  {{ $title := print .Title " | " .Site.Title }}
  {{ if .IsHome }}
    {{ $title = .Site.Title }}
     {{ else if in .RelPermalink "/posts/" }}
        {{ $title = "" }}
  {{ end }}
  <title>{{ $title }}</title>
  {{ partial "style.html" . }}
</head>

Can you spent an obvious mistake?

You are rendering the title element outside the conditions. Try the following:

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  {{ hugo.Generator }}
  {{ $summary := trim (.Summary | plainify | htmlUnescape) "\n\r"
    | default .Title }}
  <meta name="description" content="{{ $summary }}">
  <link rel="stylesheet" href="{{ "css/bootstrap.min.css" | absURL }}">
  {{ $title := print .Title " | " .Site.Title }}
  {{ if .IsHome }}
    {{ $title = .Site.Title }} <title>{{ $title }}</title>
     {{ else }}
        <title>{{ $title }}</title>
     {{ else if in .RelPermalink "/posts/" }}
        {{ $title = "" }} <title>{{ $title }}</title>
  {{ end }}
  {{ partial "style.html" . }}
</head>

Thank you! It feels like I am close but now I get the following error on the line with RelPermalink: expected end; found {{else}}

Right, the else condition should go at the very end like so:

{{ $title := print .Title " | " .Site.Title }}
  {{ if eq .Page "type" .IsHome }}
    {{ $title = .Site.Title }} <title>{{ $title }}</title>
     {{ else if in .RelPermalink "/posts/" }}
        {{ $title = "" }} <title>{{ $title }}</title>
		{{ else }}
        <title>{{ $title }}</title>
  {{ end }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.