Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{{ .Summary }} includes unwanted text in certain circumstances #1503

Open
madranet opened this Issue Oct 17, 2015 · 7 comments

Comments

Projects
None yet
6 participants
@madranet
Copy link

madranet commented Oct 17, 2015

When using {{ .Summary }} within a template, traditional markdown image tags [and their associated title and alt attributes] are ignored when the summary is created. So in a post beginning with:

![Beam me up Scotty!](/images/kirk.jpg "The Captain")

Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

The summary is correctly rendered as:

Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

However, if the {{% figure %}} shortcode is used to add images:

{{% figure src="/images/kirk.jpg" alt="Beam me up Scotty!" title="The Captain" %}}

Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

Then the title attribute is also included in the generated summary:

The Captain Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

This is also the case when caption is used:

{{% figure src="/images/kirk.jpg" alt="Beam me up Scotty!" caption="The Captain" %}}

Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

also produces:

The Captain Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

Interestingly, when both title and caption are used, only the content of the caption attribute is included in the generated summary.

Also, if a post begins with a list, this is included in the generated summary as well:

* Blah Blah
* Waffle Waffle
* Drone Drone

Lorem ipsum dolor sit amet, consectetur adipiscing elit...[etc]

Generates the following summary:

Blah Blah Waffle Waffle Drone Drone Lorem ipsum dolor sit amet, consectetur adipiscing elit.

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.

@mattwoolnough

This comment has been minimized.

Copy link

mattwoolnough commented Oct 27, 2015

+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.

@erichiller

This comment has been minimized.

Copy link

erichiller commented Oct 31, 2015

+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."

@qw3ry

This comment has been minimized.

Copy link

qw3ry commented Sep 1, 2016

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.

@madranet

This comment has been minimized.

Copy link
Author

madranet commented Jan 3, 2017

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

2017-01-03_14-05-19

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 6, 2017

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.

@stale

This comment has been minimized.

Copy link

stale bot commented Dec 6, 2017

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.

@stale stale bot added the Stale label Dec 6, 2017

@stale stale bot closed this Dec 27, 2017

@kleinschmidt

This comment has been minimized.

Copy link

kleinschmidt commented Oct 12, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.