Open madranet opened 8 years ago
+1. Code blocks turn out quite poorly also. Not formatted in any way. Strip the code blocks out as suggested, or just stop the summary at the start of the code.
+1 Agreed- this seems the perfect solutions -- @mattwoolnough "Strip the code blocks out as suggested, or just stop the summary at the start of the code."
I have a similar issue: My page is starting with a header:
# some title
and this header is included in .Summary
, but only if I use the <!--more-->
somewhere in the text.
This problem makes the "<!--more-->
-feature" quite useless for me as the resulting web page looks awful.
Disappointed to see this still hasn't been addressed as of version 0,18
$ hugo version
Hugo Static Site Generator v0.18.1 BuildDate: 2016-12-29T17:12:41Z
I for one appreciate the simplicity of the automatic summary split. Its constraints have moved me to improve my layouts by refactoring items from the content more aptly expressed in front matter.
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master
branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
This is still an issue: including a fenced code block in the summary is, IMHO, lunacy. Perhaps an option to only include the first <p>
would help?
Is this issue not a point of concern anymore? It's been more than 4 years since this issue was opened. The summary looks messed up no matter which theme I use if I start my blog post with a title or other elements other than <p>
.
I agree with @pointfourone. The "automatic" summary works well at removing images and tables, but it leaves headers in. If it ignored headers too (or if there was a site configuration variable to omit them), I think it would work quite well for me. Without it, I'm forced to copy the first paragraph or so into my front matter.
I agree with @pointfourone. The "automatic" summary works well at removing images
Summary doesn't remove images in all circumstances. See my original issue posting at the top of the thread.
Could there be a solution where you could use something like a "summary-ignore" shortcode to mark off content that you want to exclude from a summary?
envisioning something like:
{{% summary-ignore %}}
{{% figure src="/images/kirk.jpg" alt="Beam me up Scotty!" caption="The Captain" %}}
{{% /summary-ignore %}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]
Encountering the same problem here
Same Problem. Hoped I could do a workaround with the "replaceRE" Function and Regex, but it didn't worked >.<
As a workaround, I now create my own Summary-Split with a comment.
{{ $summarySplits := split .Content "<!--start-summary-->" }}
{{ if ge (len $summarySplits) 2 }}
<!-- If content has the comment "start-summary", start there -->
{{ index $summarySplits 1 | plainify | truncate 270 }}
{{ else }}
{{ .Summary| markdownify | truncate 270 " [...]" }}
{{ end }}
In my index.md, where the content is at, I add the comment at my first <p>
-Tag.
I'm seeing shortcode syntax appearing in .Summary:
Basic Code: {{< paige/vimeo "644036051" >}} Result: Video parameter Code: {{< paige/vimeo video="644036051" >}} Result: All parameters Code:
envisioning something like:
{{% summary-ignore %}} {{% figure src="/images/kirk.jpg" alt="Beam me up Scotty!" caption="The Captain" %}} {{% /summary-ignore %}} Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]
would love it
When using
{{ .Summary }}
within a template, traditional markdown image tags [and their associatedtitle
andalt
attributes] are ignored when the summary is created. So in a post beginning with:The summary is correctly rendered as:
However, if the
{{% figure %}}
shortcode is used to add images:Then the
title
attribute is also included in the generated summary:This is also the case when
caption
is used:also produces:
Interestingly, when both
title
andcaption
are used, only the content of thecaption
attribute is included in the generated summary.Also, if a post begins with a list, this is included in the generated summary as well:
Generates the following summary:
The same happens when a post begins with
## mardown headers ##
. The content of these is also included in the generated summary.All of the above make summaries generated by
{{ .Summary }}
quite messy, when posts do not start with a paragraph of text.SUGGESTION:
{{ .Summary }}
should begin summarising from the first encountered<p>
tag and should strip out any content between non text-markup tags.