I don’t know how Hugo exactly processes the summary, but here are my studies:
To see my guess, scroll down to the bottom.
I tested with this markdown content.
First content.
<img src="https://xdaforums.com/data/assets/logo/xda-white-text.png">
Pellentesque quis neque non turpis scelerisque sodales. Suspendisse ultrices magna quis nisl malesuada, non porttitor dui eleifend. Duis ac purus vitae sapien semper eleifend. Nunc sit amet massa nec nisl mollis facilisis. Vivamus quis dui eget ex dignissim ultricies id eget neque. Vivamus pharetra nibh fringilla, varius ex in, facilisis arcu. Sed at dui sit amet orci sagittis ultrices. Nam facilisis justo et neque tincidunt euismod. Nam quis ligula ac ipsum auctor rutrum et non orci. Mauris pharetra elit sed nunc dapibus, quis porta ligula pulvinar. Sed bibendum ex id sagittis ullamcorper. Suspendisse eget eros pretium, congue lacus non, posuere lacus. Quisque id augue vitae metus facilisis sollicitudin at quis ipsum. Proin tristique justo eu tellus interdum maximus. Integer pretium velit iaculis, ullamcorper purus ac, pulvinar nibh. Vivamus pellentesque enim et sem varius, at mollis lectus elementum. Donec eget tortor cursus, tincidunt elit a, sagittis nisi. Nunc iaculis quam et tortor finibus, interdum sagittis leo lobortis. Aenean quis ex viverra, viverra diam vel, posuere tellus.
The generated meta tag is like this:
<meta name="description" content="First content.
Pellentesque quis neque non turpis scelerisque sodales. Suspendisse ultrices magna quis nisl malesuada, non porttitor dui eleifend. Duis ac purus vitae sapien semper eleifend. Nunc sit amet massa nec nisl mollis facilisis. Vivamus quis dui eget ex dignissim ultricies id eget neque. Vivamus pharetra nibh fringilla, varius ex in, facilisis arcu. Sed at dui sit amet orci sagittis ultrices. Nam facilisis justo et neque tincidunt euismod. Nam quis ligula ac ipsum auctor rutrum et non orci. Mauris pharetra elit sed nunc dapibus, quis porta ligula pulvinar. Sed bibendum ex id sagittis ullamcorper. Suspendisse eget eros pretium, congue lacus non, posuere lacus. Quisque id augue vitae metus facilisis sollicitudin at quis ipsum. Proin tristique justo eu tellus interdum maximus. Integer pretium velit iaculis, ullamcorper purus ac, pulvinar nibh. Vivamus pellentesque enim et sem varius, at mollis lectus elementum. Donec eget tortor cursus, tincidunt elit a, sagittis nisi. Nunc iaculis quam et tortor finibus, interdum sagittis leo lobortis. Aenean quis ex viverra, viverra diam vel, posuere tellus.
">
This seems to ignore what I declared in hugo.yml
, though.
hasCJKLanguage: false
summaryLength: 25
But this is not that important for now.
Now I changed the content like this:
First content.
![](https://xdaforums.com/data/assets/logo/xda-white-text.png)
Pellentesque quis neque non turpis scelerisque sodales. ...
The Hugo theme I use modifies output of ![]()
and produces <p><picture><img class="img-fluid" src="https://xdaforums.com/data/assets/logo/xda-white-text.png" alt="" loading="lazy"></picture></p>
.
But the summary is cut-off like this:
<meta name="description" content="First content.
">
I put the raw HTML code into markdown like this:
First content.
<p>
<picture>
<img class="img-fluid" src="https://xdaforums.com/data/assets/logo/xda-white-text.png" alt="" loading="lazy">
</picture>
</p>
Pellentesque quis neque non turpis scelerisque sodales. ...
(HTML code is directly copied from the generated code above, without any modification)
The generated meta tag is good:
<meta name="description" content="First content.
Pellentesque quis neque non turpis scelerisque sodales. ...
">
I have a shortcode that puts HTML code into article.
First content.
{{< gallery/image src="https://xdaforums.com/data/assets/logo/xda-white-text.png" >}}
Pellentesque quis neque non turpis scelerisque sodales. ...
The result of the shortcode is <div class="gallery" align="center"><div style="width: 100%"><figure class="gallery-figure"><div class="gallery-container"><div class="gallery-inner" style="width: 100%"><picture><img class="img-fluid" src="https://xdaforums.com/data/assets/logo/xda-white-text.png" alt="" loading="lazy"></picture></div></div></figure></div></div>
.
The meta tag is broken.
<meta name="description" content="First content.
">
But if I replace shortcode part to pure HTML code like this:
First content.
<div class="gallery" align="center"><div style="width: 100%"><figure class="gallery-figure"><div class="gallery-container"><div class="gallery-inner" style="width: 100%"><picture><img class="img-fluid" src="https://xdaforums.com/data/assets/logo/xda-white-text.png" alt="" loading="lazy"></picture></div></div></figure></div></div>
Pellentesque quis neque non turpis scelerisque sodales. ...
It works again!
<meta name="description" content="First content.
Pellentesque quis neque non turpis scelerisque sodales. ...
">
So here is my guess.
Hugo can exclude pure HTML code from ‘automatic summary’.
But it completely ignores every words after ‘generated HTML code’.
Like I said before, I don’t know well about Hugo’s code, so this is just an assumption.
But I hope this tests will help devs diagnose the reason of this problem.