.Summary and <!--more--> is playing tricks on me


I’m trying to use .Summary and manually tune how much of the content will belong to summary. While automatic summaries seem to work reasonably well I have not managed to get reasonable output when using . Depending on the location of the tag I get either empty .Summary or possibly same .Summary but not the text from the beginning to the tag.

It was reproducable even in simplest possible setup with 3 Hugo files ( https://bitbucket.org/neugrund/gohugomore ).

I us “Hugo Static Site Generator v0.25.1 windows/amd64 BuildDate: 2017-07-26T01:20:59+03:00” Any help would be greatly appreciated as I’m in progress on moving Wordpress site to Hugo and summaries are used as important design element.

Best Regards,

I see only 1 content file in your example, and no summary tag.

I downloaded your repo and ran the server and I get no content in the index.html, just the boilerplate:

<html lang="et">
	<meta name="generator" content="Hugo 0.25.1" />
    <meta charset="utf-8">


So something isn’t building properly. Probably something with the way you’ve got the index.md and the layout html for index and the type “homepage” or something.

Also, for the <!--more--> keyword within the content, I’ve found that it doesn’t work unless I put it on a new line with a blank line either above or below it. Maybe there’s something strange with mine, but try that. Still, that wouldn’t cause it to not build the page.

Hello guys,

Thanks for looking at it. Sorry about confusion. I reworked my sample.

It now uses themes\test\layouts_default\list.html and themes\test\layouts_default\single.html templates.

They just use .Title and .Summary

They do render 3 pieces of content under blog, named post01.mdpost03.md

File post01.md does not contain more tag.

In files post02.md and post03.md more tag is marked with prefix “MORE COMES AFTER THIS!”.

post02.md renders as empty .Summary while post03.md renders as entire first paragraph.

I hope this sample is better.

Best Regards,

It does build properly for me. Problem is that .Summary is empty. If you remove more tag or move it around you get different results. Almost none of them is that I expect. I expect .Summary to contain text from the beginning of content up to more tag.

There is related issue with fix and there are few other reports that issue is still there

I chased down the source of the issue

It clearly misbehaves, for example Summary depends on whether more tag is in first half or second half of the paragraph. I would be happy to fix it, although I’m not even able to guess from the code how it should behave. I see 2 options.

  1. From the beginning of the document to closing paragraph tag. Closest to the current behavior, although not exactly how similar tag works in Wordpress.

  2. Make it work like it is described in documentation. Everything before tag is included in summary. That would provide exact control for Summary but can return invalid HTML if tag is in the middle of the paragraph.

Any feedback on how to proceed?

Best Regards,

I prefer the 2nd way, personally. That way you can put it inline. Which I think is how Jekyll works.