【问题标题】:Trying to add additional page to Jekyll site尝试向 Jekyll 站点添加其他页面
【发布时间】:2017-10-03 00:10:56
【问题描述】:

我最近使用 Jekyll 建立了我的新博客/作品集网站。我自定义的主题只有主页,也是帖子页面,然后是关于我的页面。

我正在尝试添加一个新页面,项目,这将类似于主页,但会列出项目,就像在主页(索引)页面上列出的帖子一样。

我能够让项目链接显示在导航栏中,当我单击它时,它会将我带到正确的 URL。模板的其余部分在那里,但我在项目文件夹中的示例文件没有显示。我在这里做错了什么?

这是我的目录树

├── CNAME
├── CODE_OF_CONDUCT.md
├── LICENSE
├── _config.yml
├── _includes
│   ├── analytics.html
│   └── head.html
├── _layouts
│   ├── about.html
│   ├── default.html
│   ├── post.html
│   └── project.html
├── _posts
│   ├── 2017-03-09-developer-goals.md
│   ├── 2017-03-09-finding-web-dev.md
│   ├── 2017-03-09-my-experience.md
│   ├── 2017-09-16-example-content.md
│   └── 2017-09-17-jumping-into-react.md
├── _projects
│   └── 2017-03-09-developer-goals.md
├── _sass
│   ├── _base.scss
│   ├── _catalogue.scss
│   ├── _code.scss
│   ├── _layout.scss
│   ├── _pagination.scss
│   ├── _post.scss
│   ├── _syntax.scss
│   └── _variables.scss
├── _site
│   ├── 2017-03-09
│   │   ├── developer-goals.html
│   │   ├── finding-web-dev.html
│   │   └── my-experience.html
│   ├── 2017-09-16
│   │   └── example-content.html
│   ├── 2017-09-17
│   │   └── jumping-into-react.html
│   ├── CNAME
│   ├── CODE_OF_CONDUCT.md
│   ├── LICENSE
│   ├── about
│   │   └── index.html
│   ├── favicon.ai
│   ├── favicon.png
│   ├── index.html
│   ├── project
│   │   └── index.html
│   └── styles.css
├── about.md
├── favicon.ai
├── favicon.png
├── index.html
├── projects.html
└── styles.scss

这是我的projects.html 文件

---
layout: default
title: "Projects"
author: "Steven"
permalink: /project/
---

<div class="catalogue">
  {% for project in paginator.project %}
    <a href="{{ project.url | prepend: site.url }}" class="catalogue-item">
      <div>
        <time datetime="{{ project.date }}" class="catalogue-time">{{ project.date | date: "%B %d, %Y" }}</time>
        <h1 class="catalogue-title">{{ project.title }}</h1>
        <div class="catalogue-line"></div>

        <p>
          {{ project.content | truncatewords: 30 | strip_html }}
        </p>

      </div>
    </a>
  {% endfor %}
</div>

<div class="pagination">
  {% if paginator.previous_page %}
    <a href="{{ paginator.previous_page_path | prepend: site.url }}" class="left arrow">&#8592;</a>
  {% endif %}
  {% if paginator.next_page %}
    <a href="{{ paginator.next_page_path | prepend: site.url }}" class="right arrow">&#8594;</a>
  {% endif %}

  <span>{{ paginator.page }}</span>
</div>

这是我的project.html 文件:

---
layout: default
---

<div class="post">

  <h1 class="post-title">{{ page.title }}</h1>
  <div class="post-line"></div>

  {{ content }}

</div>

这种布局和设计非常简单,但就是想不通为什么这不起作用。任何帮助深表感谢!也可以随时查看现场直播,stevenmills.io

【问题讨论】:

    标签: html ruby templates jekyll


    【解决方案1】:

    以下划线开头的文件夹对于 Jekyll 来说是特殊的。在这种情况下,_projects 似乎不是集合或其他东西,因此 Jekyll 将忽略它。

    去掉开头的下划线,在里面添加一个_posts文件夹:

    projects/_posts/2017-03-09-developer-goals.md
    

    那么2017-03-09-developer-goals.md 帖子也会有projects 类别。

    【讨论】:

      猜你喜欢
      • 2015-07-29
      • 2016-04-04
      • 1970-01-01
      • 2022-11-20
      • 1970-01-01
      • 1970-01-01
      • 2013-10-19
      • 2016-07-31
      • 2011-02-25
      相关资源
      最近更新 更多