1:在主题配置文件里添加键值对 添加键值对的目的是,控制截取长度和自动截取功能是否开启。在你的博客目录\themes\volantis\_config.yml下添加
1 2 3 4 5 6 auto_excerpt:     enable:  true      lines:  5  
 
2:修改文章代码 修改\themes\volantis\layout\_partial文件内容为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 <article class="post white-box <%- theme.style.body.effect.join(' ') %> reveal <%= (post.title) ? "" : "no-title" %>">   <%- partial('meta',{post:post, position:'header'}) %>   <section class="article typo">     <div class="article-entry" itemprop="articleBody">       <% var show_all_content = true %>       <% if (post.excerpt) { %>         <% show_all_content = false %>         <%- post.excerpt %>       <% }  else if (post.summary) { %>         <% show_all_content = false %>         <p><%- post.summary %></p>       <% } else if (theme.auto_excerpt.enable) { %>         <% var br_position = 0 %>         <% for (var br_count = 0; br_count < theme.auto_excerpt.lines; br_count++) { %>             <% br_position = post.content.indexOf('\n',br_position + 1) %>             <% if(br_position < 0) { break } %>         <% } %>         <% if(br_position > 0) { %>             <% show_all_content = false %>             <p><%- post.content.substring(0, br_position + 1) %><p>         <% } %>       <% } %>       <% if (show_all_content) { %>         <%- post.content %>         <% } %>     </div>     <% if (theme.layout.on_list.readmore) { %>       <% if ((post.readmore != false) && (show_all_content != true)) { %>         <div class="button readmore">           <a href="<%- url_for(post.link || post.path) %>">             <%- theme.layout.on_list.readmore %>           </a>         </div>       <% } %>     <% } %>   </section> </article> 
 
上面的代码逻辑,是,如果有more标签,则使用more标签前的文字作为摘要,非则使用md文章scaffolds里的summary内容作为摘要,主题原来用的scaffolds是description。如果需要用description,可以自行替换上面的代码。
在scaffolds\post.md里可以修改新建md文件生成的scaffold。
 
重要!!这种方法是直接提取的文章前5行。如果提取到的内容里,包含代码块的一部分,那么由于渲染问题布局将会出现问题。建议如果你的文章前面里有代码,自行在summary里写摘要,或者more标签前写摘要。
 
3:参考文献 《Hexo 自动给博文添加 ReadMore 》