I tried to upgrade from 0.140.0 to 0.160.0 with all new folder structure. But I still got broken layout. So I switched back to 0.140.0 with old folder structure.
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.
While your code works perfectly fine, you can eliminate the duplicate code in your template altogether by moving the mode div outside of the conditional logic. This also makes your template easier to maintain:
<div class="paginator">
{{ if eq .Section "poem" }}
{{ $next := .Next | default . }}
<a class="left" role="button" href="{{ if and (eq $next.Section .Section) (ne $next .) }}{{ $next.Permalink }}{{ else }}#{{ end }}">«</a>
{{ else }}
{{ $prev := .Prev | default . }}
<a class="left" role="button" href="{{ if and (eq $prev.Section .Section) (ne $prev .) }}{{ $prev.Permalink }}{{ else }}#{{ end }}">«</a>
{{ end }}
<!-- Kept outside the IF statement so it only needs to be written once -->
<div id="mode" class="favicon">
<div id="dark"><img alt="{{ .Site.Title }}" src="{{ .Site.BaseURL }}favicon.svg"></div>
<div id="light" hidden><img alt="{{ .Site.Title }}" src="{{ .Site.BaseURL }}favicon.svg"></div>
</div>
{{ if eq .Section "poem" }}
{{ $prev := .Prev | default . }}
<a class="right" role="button" href="{{ if and (eq $prev.Section .Section) (ne $prev .) }}{{ $prev.Permalink }}{{ else }}#{{ end }}">»</a>
{{ else }}
{{ $next := .Next | default . }}
<a class="right" role="button" href="{{ if and (eq $next.Section .Section) (ne $next .) }}{{ $next.Permalink }}{{ else }}#{{ end }}">»</a>
{{ end }}
</div>
Also, avoid using {{ .Site.BaseURL }} in templates. It is undocumented. Use the following: