hexo new page tags 页面内容为空

Created on 12 Apr 2016  ·  9Comments  ·  Source: hexojs/hexo

hexo: 3.2.0
hexo-cli: 1.0.1
os: Darwin 15.4.0 darwin x64
http_parser: 1.0
node: 0.10.35
v8: 3.14.5.9
ares: 1.9.0-DEV
uv: 0.10.30
zlib: 1.2.8
modules: 11
openssl: 1.0.1j

主题是landspace.

执行 hexo new page tags 后在source目录下多了tags目录,下面有一个生成好的index.md,内容如下:

title: 标签

date: 2016-04-12 02:09:02

开启/tags路由后,访问页面内容仅显示两个字:标签,HTML如下

标签

请问是什么原因?

另外,theme下的layout,category.ejs,tag.ejs是如何引用的?谢谢!

Most helpful comment

方法一:
在生成的index,md中加入

title: Tags
layout: tag // 引用theme下的layout中tag.ejs
date:
type: "tags"

方法二:
md中没有layout。在theme下的layout的page.ejs中配置,根据路径page.path判断,例如:
<% if(page.path == "tags") { %>
<%- partial('casper/tag', {post: page}) %>
<% } %>

如果index.md不配置layout和page.ejs中不判断只partial一个页面,最后分类、标签、关于页面可能都显示了partial的这个页面

All 9 comments

hexo  new page tags

这句命令的意思是新建一个page(页面),起名叫“tags”。

这就是一个普通的page,只是名字叫tags而已,所以你访问 /tags 可以看到。

Tags index page requires https://github.com/hexojs/hexo-generator-tag/ and theme support.
Landscape does not support this.

See for example https://github.com/ppoffice/hexo-theme-minos#custom-categories--tags-pages
There are other themes too but the layout name in (_source/tags/index.[html|md]) may be different.

@leesei Thx.

我遇到了题主一样的问题,提供一种解决情况供参考。
我使用的是ppoffice的icarus主题,受 @leesei 的启发,发现主题目录下有一个[“_source”文件夹](它里面的内容正是about,categories,tags分别已写好的index.md)。复制到[Hexo根目录/source文件夹]内覆盖,就可以了。

方法一:
在生成的index,md中加入

title: Tags
layout: tag // 引用theme下的layout中tag.ejs
date:
type: "tags"

方法二:
md中没有layout。在theme下的layout的page.ejs中配置,根据路径page.path判断,例如:
<% if(page.path == "tags") { %>
<%- partial('casper/tag', {post: page}) %>
<% } %>

如果index.md不配置layout和page.ejs中不判断只partial一个页面,最后分类、标签、关于页面可能都显示了partial的这个页面

@chenxjGit Thanks. 终于找到解决方法了

@chenxjGit 不知道你用没有用过jacman这个模板,这个模板里面的layout是tags,但是对应的theme下的layout中没有tag.ejs。而是在theme/layout/_particl中有tags.ejs。也一样能引用到。而我在landscape中自己新建了一个theme/layout/_particl/tags.ejs却引用不到,这是什么原因呢!请教一下。。

@chenxjGit 最蛋疼的一个问题是,在hexo generate中,提示page.posts是一个undefined的属性。
Unhandled rejection TypeError: /Users/luowen/work/blog/themes/landscape/layout/tag.ejs:1

1| <%- partial('_partial/archive', {pagination: config.tag, index: true}) %>
2|

<%- is_tag() %>

/Users/luowen/work/blog/themes/landscape/layout/_partial/archive.ejs:7
5| <% } else { %>
6| <% var last; %>

7| <% page.posts.each(function(post, i){ %>
8| <% var year = post.date.year(); %>
9| <% if (last != year){ %>
10| <% if (last != null){ %>

Cannot read property 'each' of undefined

hexo  new page tags

这句命令的意思是新建一个page(页面),起名叫“tags”。

这就是一个普通的page,只是名字叫tags而已,所以你访问 /tags 可以看到。

那这样这个page和post有啥区别?感觉和文章一样也是md,而且还不会自动出现在文章列表里面。

Was this page helpful?
0 / 5 - 0 ratings