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

About variable "page.excerpt" #1143

Hill1942 opened this issue Mar 25, 2015 · 6 comments

About variable "page.excerpt" #1143

Hill1942 opened this issue Mar 25, 2015 · 6 comments


Copy link

when I try to get the value of page.excerpt by <%= page.excerpt %>, there's nothing out.

So where to define page.excerpt?

Copy link

jorgt commented Mar 25, 2015

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.

Copy link

bvodola commented May 15, 2015

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.


Edit: You can also use this hexo-front-matter-excerpt plugin to define the excerpt in the front matter with whatever content you want.


Copy link

@bvodola thanks brother, you help me! thanks

@leesei leesei closed this as completed Jul 16, 2015
Copy link

0326 commented Dec 5, 2015

it works! thanks @bvodola

Copy link

@bvodola thanks
I've been trying to solve this problem for hours QAQ

Copy link

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

  • "hexo": "^3.3.8"
  • "hexo-renderer-ejs": "^0.1.0"
  • "hexo-renderer-marked": "^0.2.4"
            <% 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 %>
                    <p class='padding-bottom-10'>
                    <% post.tags.each(function(tag){ %>
                        <span class="tag"><%= %></span>
                    <% }); %>
                    <p>Excerpt: <%- post.excerpt %></p>
                      <%= date(, config.date_format) %> 
            <% }); %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

8 participants