Search code examples
htmltemplatesjekyll

Jekyll not rendering templated page


I'm running Jekyll 4.0.0 and Bundler version 1.17.2. As this time of posting, it is the latest version of both Jekyll and Bundler.

I have a template called default, which I use to standardize the appearance of navbar, footer, and location of content being displayed.

The directory structure of my website is as follows:

  • _data: a folder of yml data files for listings of open source projects I worked on

  • _includes: a folder containing footer and navbar html files

  • _layouts: a folder containing liquid templated layout files. This is where "default.html" layout file is located.

  • _posts: a directory of blog posts that I want rendered by Jekyll

  • CNAME img: image files index.html credits.html

  • lib: a directory that hosts all of my CSS, fonts, JavaScript files

  • logo.ico

  • opensource: a folder containing layouts related to open source

What I'm having trouble with is adding the credits.html page. Using index.html as a template (since index.html renders perfectly), I have the following meta data pasted at the top of credits.html:

---
title: <my name>
layout: default
description: <my description>
---

Under that are all the HTML related to the contents section of the page. When I test my website locally and on github pages, I noticed Jekyll gives me a 404 not found error. I know this is not true because the moment I put credits.html inside another folder (ie: /credits/credits.html) the page renders fine with the url localhost:4000/credits/credits.

I do have permalink set as "pretty" for the entire static website.

Does anyone know why I can't seem to render the credits page? The index page seems to work just fine. I've tried digging through the documentation, but I can't seem to figure out what is affecting that one page.

** EDIT ** I discovered that if I go to localhost:4000/credits/, the page renders perfectly. This is definitely a permalink issue. Can someone point me in the right direction of how I can fix this issue?


Solution

  • I solved the issue!

    The reason is because I had permalink enabled in the global configuration file "_config.yml". Inside that file, I had permalink: pretty set. This is why localhost:4000/credits/ worked but not localhost:4000/credits.html.

    To resolve this issue, I removed that setting from the global config file. I also realized at the same time that permalink was not necessary for my use case.

    For anyone who is in this situation but requires permalink for other sections of your website, set permalink per template file via front matter instead.