'GitHub pages post links not working
I'm trying to get a Git Hub pages blog to work (https://vcedgar.github.io/CREU-Poly-17/), but when I go to the link my posts are supposed to be on the link doesn't work (404 page not found or 404 file not found.) The really weird this is that I have a page that displays a list of posts, and the post is showing up there just fine (date published, title, and blurb.) But when I click o the link from that page, it doesn't work. I have also gotten it to work sometimes, but then aftera while if I refresh the page it gives a 404.
Here's the code:
_config.yml
name: CREU 2017 Vatricia Edgar
markdown: kramdown
permalink: /CREU-Poly-17/:title
future: true
default layout
<!DOCTYPE html>
<html>
<head>
<title>{{ page.title }}</title>
<!-- link to main stylesheet -->
<link rel="stylesheet" type="text/css" href="/CREU-Poly-17/css/main.css">
</head>
<body>
<h1 class = "head">CREU-17</h1>
<nav>
<ul>
<li><a href="/CREU-Poly-17/">Home</a></li>
<li><a href="/CREU-Poly-17/About/">About</a></li>
<li><a href="/CREU-Poly-17/Blog/">Blog</a></li>
</ul>
</nav>
<h2 class = "head">{{page.title}}</h2>
<div class="container")
{{ content }}
</div><!-- /.container -->
<footer>
<ul>
<p><a href="mailto:[email protected]">email</a></p>
<p><a href="https://github.com/vcedgar">github</a></p>
</ul>
</footer>
</body>
</html>
the post:
---
layout: default
title: Week1
date: 2017-09-01
published: true
---
fist post.
Also, here is the file/folder organization, in case that is relevant: About and Blog just contain the index.html for the About and Blog pages, _layout contains the default layout and the layout I wanted to use for posts (switched to default for posts to see if it would help, didn't), css obviously contains the css file (only one rn) and _posts contains the post file. My GitHub repo
I've been having trouble with my links on the blog ever since I started making it, but this one has stumped me. Any help is appreciated!
Solution 1:[1]
I'm not sure if it's an actual issue but it's recommended in the documentation of Jekyll to name post files in lower case, so that might be a reason the page is not generated correctly.
If that also doesn't help I would get rid of case sensitivity in the path too and I'd not use the same folder for sites as well as pages. So in worst case remove the permalink setting in _config.yml, so that the default post link structure is used.
You can also have a look at my Jekyll powered GitHub Page as reference:
EDIT: The OP's GitHub page is obviously running in a sub-directory. That's why even after using default permalinks, for getting it run he had to put the sub-directory in front of links like <a href="/CREU-Poly-17{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a>
. A more beautiful solution would be to put the sub-directory in the _config.yml as baseurl as stated in the answer of David Jacquel.
Solution 2:[2]
In _config.yml :
url: https://vcedgar.github.io
baseurl: /CREU-Poly-17 #NO TRAILING SLASH
In your links : <a href="{{ site.baseurl }}/CREU-Poly-17/">Home</a>
Solution 3:[3]
You have to take the relative url when deploying through github pages.
In Github as you make the site the repository name is included in the page url, thus all absolute links appear to be void. You can solve it by adding a few liquid lines as follows,
{{ post.url | relative_url }}
Further if you would like to add backslash in the urls use the following
<link href="{{'your url including /home/eas/boot/sd.css' | relative_url}}" rel="stylesheet">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | David Jacquel |
Solution 3 |