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

分类无法正常使用 #2209

Open
xiaoli1368 opened this issue Jun 26, 2019 · 3 comments
Open

分类无法正常使用 #2209

xiaoli1368 opened this issue Jun 26, 2019 · 3 comments

Comments

@xiaoli1368
Copy link

按照相关教程实现文档添加标签和分类功能后,标签的相关功能可以正常实现,但是分类功能出现错误,具体表现为:

  • 可以正常生成public内的categories文件夹,但是点击网页左边侧边栏“分类”的时候出现空白,仅存在“分类”这一标题而没有其它任何内容,并且在左边侧边栏也可以看到相应的分类个数,如“15 categories”,但是依然无法点击。(相对于的,关于tags的内容是可以点击的)
  • 而当从其它页面正常打开一篇文档的时候,发现可以正常阅读,并且顶部会显示相应的该文章的分类信息,且可以点击进入对应的分类后的子类的链接,显示正常

因此分析得出categories页面的配置文件有问题,但是又不知道问题出在那里,,经过查看所使用next主题的categories配置文件为category.swig,如下所示:

{% extends '_layout.swig' %}
{% import '_macro/post-collapse.swig' as post_template %}
{% import '_macro/sidebar.swig' as sidebar_template %}

{% block title %}{{ __('title.category') }}: {{ page.category }} | {{ config.title }}{% endblock %}

{% block content %}

  {######################}
  {### CATEGORY BLOCK ###}
  {######################}
  <div class="post-block category">

    <div id="posts" class="posts-collapse">
      <div class="collection-title">
        <{% if theme.seo %}h2{% else %}h1{% endif %}>{#
        #}{{ page.category }}{#
        #}<small>{{  __('title.category')  }}</small>
        </{% if theme.seo %}h2{% else %}h1{% endif %}>
      </div>

      {% for post in page.posts %}
        {{ post_template.render(post) }}
      {% endfor %}
    </div>

  </div>
  {##########################}
  {### END CATEGORY BLOCK ###}
  {##########################}

  {% include '_partials/pagination.swig' %}

{% endblock %}

{% block sidebar %}
  {{ sidebar_template.render(false) }}
{% endblock %}

请高手帮忙解决一下,不胜感激?

@cogito0823
Copy link

cogito0823 commented Jul 5, 2019

需要新建一个 categories 页面。
具体如下:

  • 在blog根目录下输入命令
hexo new categories
  • 提示在source目录下生成了一个叫categories的新目录,该目录包含一个index.md文件,编辑该文件显示如下:
---
title: categories
date: 2019-07-05 15:08:49
---

将其修改为:

---
title: categories
date: 2019-07-05 15:08:49
type: "categories"
---

重新生成,部署。就ok了
标签等页面类似,将type 改成对应的类型即可,如tags 的类型改成 "tags"
ok! 欢迎进入我的博客 https://cogito0823.github.io 一起交流学习呀~

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Aug 1, 2019

此问题已在新版中解决,本仓库不再维护。请查看:https://github.com/next-theme/hexo-theme-next

@xiaoli1368
Copy link
Author

xiaoli1368 commented Aug 2, 2019 via email

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

No branches or pull requests

3 participants