.Content doesn't return all the post content if the post has a <!-- more --> comment

Hello, I am porting an old blog to Hugo. Some of the existing posts have the special <!--more--> comment to indicate that the text above it can be used as the summary of the post.

My problem is that in my template for the post view, if I just do this:

          <div>
              {{ .Content }}
           </div>

…then I only get the text below the <!--more-->. So the top of the post is missing.

If I do the this:

          <div>
              {{ .Summary }}
              {{ .Content }}
           </div>

, then posts with a <!--more--> tag render properly, but posts without that tag render an auto-generated summary at the top, and the the entire post contents, so they have a chunk of duplicated text at the top.

Is there a way to get all the post content in a consistent manner, for posts with or without a <!--more--> tag?

Hi @masonmark. You could tweak this snippet to meet your needs: How to check the summary divider presence

1 Like