gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.5k stars 7.51k forks source link

Summary should not include shortcodes #5619

Closed pjebs closed 5 years ago

pjebs commented 5 years ago
By default, Hugo automatically takes the first 70 words of your content as its summary and stores it into the .Summary page variable for use in your templates. 

Automatic summary splitting should ignore the contents inside the shortcode file

bep commented 5 years ago

Why?

pjebs commented 5 years ago

Here is my shortcode:


<script>
var parentTag = document.scripts[document.scripts.length - 1].parentNode;
{{ with .Get "tags"}} parentTag.setAttribute('data-tags', '{{.}}') {{ end }}
{{ with .Get "debug"}} parentTag.setAttribute('data-debug', '{{.}}') {{ end }}
{{ with .Get "placement"}} parentTag.setAttribute('data-placement', '{{.}}') {{ end }}
{{ with .Get "width"}} parentTag.setAttribute('data-width', '{{.}}') {{ end }}
{{ with .Get "color"}} parentTag.setAttribute('data-color', '{{.}}') {{ end }}
{{ with .Get "margin"}} parentTag.setAttribute('data-margin', '{{.}}') {{ end }}
{{ with .Get "resolution"}} parentTag.setAttribute('data-resolution', '{{.}}') {{ end }}
{{ with .Get "gap"}} parentTag.setAttribute('data-gap', '{{.}}') {{ end }}
{{ with .Get "labels"}} parentTag.setAttribute('data-labels', '{{.}}') {{ end }}
{{ with .Get "baseline"}} parentTag.setAttribute('data-baseline', '{{.}}') {{ end }}
{{ with .Get "padding"}} parentTag.setAttribute('data-padding', '{{.}}') {{ end }}
</script>

Here is my content:

{{< gutter debug="false" placement="left" color="red,green" width="5" margin="1" padding="5" resolution="1" gap="0" tags="xxx,zzz" >}}

## Ktaadn
dsgasg
dsgsadg

Here is the summary produced:

var parentTag = document.scripts[document.scripts.length - 1].parentNode; parentTag.classList.add("ths-gutter"); parentTag.setAttribute('data-tags', 'xxx,zzz') parentTag.setAttribute('data-debug', 'false') parentTag.setAttribute('data-placement', 'left') parentTag.setAttribute('data-width', '5') parentTag.setAttribute('data-color', 'red,green') parentTag.setAttribute('data-margin', '1') parentTag.setAttribute('data-resolution', '1') parentTag.setAttribute('data-gap', '0') parentTag.setAttribute('data-padding', '5') Ktaadn On the 31st of August, 1846, I left Concord in Massachusetts for Bangor and the backwoods of Maine, by way of the railroad and steamboat, intending to accompany a relative of mine engaged in the lumber-trade in Bangor, as far as a dam on the west branch of the Penobscot, in which property he was interested.
bep commented 5 years ago

I would suggest that you do that kind of formatting outside of content files. As a general rule, shortcodes are part of Content.

For troubleshooting how you can solve your particular issue, use https://discourse.gohugo.io/

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.