How would I include the page summary in the post body?
So I always create a summary
for every post, this is within the front matter of each post and is used for the description
with the HTML meta.
I also use this summary as a line of intro text for every post. At the moment, I copy/paste the summary
into the body of the post, but it would be nice if this was rendered automatically at build.
I've tried including {{{summary}}}
in the body, but it doesn't render.
How would I get the summary
to render in my posts?
I don’t know, but maybe the Teaser parameter would work for you.
Teaser:
Defaults to the first few paragraphs of the post. You can specify a teaser in the file’s metadata or insert the breakpoint {{more}}
yourself. You can specify the end of the teaser using the {{more}}
tag somewhere in the file.
Everything above the {{more}}
tag, including this line, will be in the post’s teaser
If it has to be a “summary” specifically, maybe there’s a way to reference the teaser as the summary in your front matter. Something like this?
---
Summary: {{teaser}}
---
– Jarrod
Answered a year ago · Edit answerYou'll want to modify your template, and replace the usage of the {{{html}}}
tag in both entries.html and entry.html with the following:
{{{titleTag}}}
<p>{{summary}}</p>
{{{body}}}
If your post looks like this:
Summary: Your summary here
# Title
The first sentence.
The resulting HTML generated by your template should be:
<h1>Title</h1>
<p>Your summary here</p>
<p>The first sentence.</p>
Does that make sense? Please let me know if you have any questions about this or anything else
Answered a year ago · Edit answerThat does make sense, thanks. I'll just need to go back and delete the first sentence on all my posts now. 😳
Answered a year ago · Edit answer