Steven Mills
Steven Mills

Reputation: 15

Trying to add additional page to Jekyll site

I recently set up my new blog / portfolio site using Jekyll. The theme I customized only had the home page which was also the posts page and then an about me page.

I am trying to add a new page, projects, that will be similar to the home page, but will list out projects just like the posts are listed out on the home(index) page.

I am able to get the projects link to show in the nav bar and when I click it, it takes me to the correct URL. The rest of the template is there, but the example file that I have in the projects folder isn't showing. What am I doing wrong here?

Here is my directory tree

├── 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

Here is my projects.html file

---
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>

Here is my project.html file:

---
layout: default
---

<div class="post">

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

  {{ content }}

</div>

This layout and design is super simple, but just can't figure out why this isn't working. Any help is much appreciated! Also feel free to check out the site live, stevenmills.io

Upvotes: 1

Views: 321

Answers (1)

marcanuy
marcanuy

Reputation: 23952

Folders that start with an underscore are special for Jekyll. In this case it seems that _projects isn't a collection or something else, so it will be ignored by Jekyll.

Remove the leading underscore and add a _posts folder inside:

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

Then the 2017-03-09-developer-goals.md post would have the projects category too.

Upvotes: 1

Related Questions