when I try to get the value of page.excerpt by <%= page.excerpt %>, there's nothing out.
So where to define page.excerpt?
Same issue with posts. post.excerpt is always available but always empty. This is using 3.0.0.
I tracked the offending code to the regex in hexo/lib/plugins\filter\after_post_render\excerpt.js
I'm using this code until this is patched. It works for me but has not been tested on anything but my theme.
Use a html comment with the word "more" to mark the excerpt of your post, like this:
title: post title
---
This part is the excerpt, get it with the <%- post.excerpt %>
<!-- more -->
This is the rest of the post. You can get it with <%- post.more %>
All the text after the <!-- more --> is only displayed when you view the page of the post.
Font: https://groups.google.com/forum/#!topic/hexo/cdbCM0lb9A0
Edit: You can also use this hexo-front-matter-excerpt plugin to define the excerpt in the front matter with whatever content you want.
Cheers!
@bvodola thanks brother, you help me! thanks
it works! thanks @bvodola
@bvodola thanks
I've been trying to solve this problem for hours QAQ
I am also having an error rendering the post.excerpt. I specified more in my blog posts but when I look at the source, excerpt is always set to an empty string, despite the more html comment. This is the code I am using to grab the excerpt that does not render it.
I am using
<% site.posts.each(function(post, i){ %>
<div class='notification is-danger post'>
<a href="<%- url_for(post.path) %>" class='underline-link' style='padding-bottom: 8px;'>
<%= post.title %>
</a>
<p class='padding-bottom-10'>
<% post.tags.each(function(tag){ %>
<span class="tag"><%= tag.name %></span>
<% }); %>
</p>
<p>Excerpt: <%- post.excerpt %></p>
<p>
<%= date(post.date, config.date_format) %>
</p>
</div>
<% }); %>
Most helpful comment
Use a html comment with the word "more" to mark the excerpt of your post, like this:
All the text after the
<!-- more -->is only displayed when you view the page of the post.Font: https://groups.google.com/forum/#!topic/hexo/cdbCM0lb9A0
Edit: You can also use this hexo-front-matter-excerpt plugin to define the excerpt in the front matter with whatever content you want.
Cheers!