Content adapters: content summary not working

In content adapters, content summary seems to have two problems (A and B).

Below is my public repository for testing this.

Local data: /data/posts.json
There are post 1~4.

/post/_content.gotmpl

{{ range .Site.Data.posts }}
  {{ $content := dict
    "mediaType" "text/markdown"
    "value" .content
  }}
  {{ $dates := dict
    "date" (time.AsTime .date)
  }}
  {{ $params := dict
    "tags" .tags
  }}
  {{ $page := dict
    "content" $content
    "dates" $dates
    "kind" "page"
    "params" $params
    "path" .title
    "title" .title
    "summary" .summary
  }}
  {{ $.AddPage $page }}
{{ end }}

Problem A. Manual summary not works

Post 1 is automatic summary case. In hugo.yaml, summarylength: 80. This works.

Post 3 is front matter summary case. In posts.json, for post 3 "summary": "Lorem ipsum dolor sit amet, usu cu atqui sensibus.". This works, too.

But, Post 2. This is manual summary case. In content of post 2, there are <!--more--> divider. This appears not to work.

Problem B. Shortcode in summary not works

Post 4 is Automatic summary with shortcode case. There are twitter shortcode. But, the shortcode appears not to render in summary.

Anyone have a solution?

Apologies for my poor English.

This sets the summary field in front matter, so rendering {{ .Summary }} follows these rules:
https://gohugo.io/content-management/summaries/#comparison

The shortcode is at the beginning of the string. Did you update hugo to 126.2?

Regarding the more tag I had the feeling, that op is right. I experienced that also one time. Will need to recheck.

OK, I see the problem.

With Post 2 we’re ignoring the <!--more--> separator. This is a bug, but may be expensive to resolve[1]… this may ultimately be a documentation issue.

With Post 4, an automatic summary, we’re doing the right thing. We’re rendering the shortcode, then stripping out the HTML. This is consistent with:

https://gohugo.io/content-management/summaries/#comparison

The characteristics described in the comparison table above aren’t great. See this issue.

To fix Post 4 you need to make it a manual summary, but that won’t work per the <!--more--> separator bug above.



  1. I’m pretty sure the <!--more--> separator parsing is done before markdown processing, and I think we’re bypassing that step with content adapters. ↩︎

just rechecked my simple summary test on content adapters:

verified that it’s ignoring

startup guide hugo setup

_content.gotmpl

   {{ $content := dict
      "mediaType" "text/markdown"
      "value" "Before more<!--more-->After More"
   }}
   {{ $page := dict
      "content" $content
      "kind" "page"
      "path" "post-4"
      "title" "post-4"
   }}
   {{ $.AddPage $page }}
## post-4
Before moreAfter More

I’ve logged a proposal to support the <!--more--> separator:
https://github.com/gohugoio/hugo/issues/12556

But I’m not optimistic that it will be accepted.

2 Likes

To irkode and jmooring, Thanks for your responses, and sorry for the late reply due to the time difference.

I also apologise for the lack of necessary information. My Hugo is v0.126.2+extended.

I understood the function of automatic summary (Post 4 case) incorrectly. Thank you so much for your instruction.

O.K. I understand. Thank you for your efforts.

This is fixed in the next release.

2 Likes

Oh, that is great. So many thank you !!

Wow. U guys are great

checked with 126.3 - works for me

Me too. With Hugo 0.126.3, manual summary and shortcode works fine. Thanks a lot!!

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