.Summary .Content and the second part of .Content

The question is “Is there a way to strip the .Summary from the .Content so that I get the rest only?” There was a discussion on this problem in 2016-2018 on this forum and this fine decision was found:

{{ $body := replace .Content .Summary "" }}			{{ $body | safeHTML }}

However I need not two parts of content but three parts.
In my markdown file I have written:

First part of content (aka summary): short description of the book
 <!--more-->
 More about the book. Some critical notes
<!-- content break -->
Biography of the writer and her other books

In my single.html I have this:

 <p>
            {{ .Summary }}
          </p
		  
...
		  
		 <div id="nav-tabContent">
		 {{- $sectionDelimiter := "<!-- content break -->" -}}
		{{- $rawContentSections := split .RawContent $sectionDelimiter -}}
		{{- if gt (len $rawContentSections) 1 -}}
 
		  <div id="nav-home">
             {{ index $rawContentSections 0 | .RenderString }}
          </div>
		  
          <div id="nav-profile">
		     {{ index $rawContentSections 1 | .RenderString }}
		  </div>  
           {{- else -}}
			
			<div id="content-not-split-into-sections">
			{{ $body := replace .Content .Summary "" }}
			{{ $body | safeHTML }}
			</div>
			{{- end -}}
              
        </div>
         

If content is not split into sections (the part after {{else}}) the decision of 2016-2018 works fine and I get Content without Summary. But how can I change the first part of html before {{else}} to get the same result? I tried to make a few tweaks but to no avail.

https://gohugo.io/methods/page/contentwithoutsummary/

1 Like

Thank you but my theme is for Hugo 0.126.1. Is there any simple solution for me?

Split the raw content on <!--more--> to get the summary and remainder, then split the remainder on <!-- content break -->.

1 Like

Thank you! I’ll try.