Jekyll/Github Pages -- index.html not being written? - html

Cross-posted in a Github issue at https://github.com/SeanKilleen/seankilleen.github.io/issues/189
Digging into an issue with GitHub pages that appears like it might be recent.
I noticed an up-tick in 404s via Google Analytics. It appears that posts with trailing slashes are becoming 404'd, but appeared just fine without the slash.
My local Jekyll instance generates the following structure for how-to-leave-a-company-well.md from Feb 2015:
/2015
/02
/how-to-leave-a-company-well.html
/how-to-leave-a-company-well
/index.html
So, the following URLs work just fine locally:
http://localhost:4000/2015/02/how-to-leave-a-company-well
http://localhost:4000/2015/02/how-to-leave-a-company-well.html
http://localhost:4000/2015/02/how-to-leave-a-company-well/index.html
http://localhost:4000/2015/02/how-to-leave-a-company-well/
Those last two URLs that I've bolded do not seem to exist on my published site after GitHub Pages generates the documents.
I cannot reach http://seankilleen.com/2015/02/how-to-leave-a-company-well/ or http://seankilleen.com/2015/02/how-to-leave-a-company-well/index.html
This seems to indicate to me that GitHub Pages is doing something differently than my Jekyll installation. Given that the 404 spike is recent, I'm wondering if there might have been a change related to this.
Does anyone have a thought on how I might be able to diagnose this? It's a bit of a black box for me when my local is doing what I expect and I can't see the Github Pages process.

Jekyll 3 changed the way the permalinks worked, and dropped the trailing slash if your permalink setup did not contain one - yours does not contain a trailing slash at the end of your permalink in the config file. Jekyll 3 now respects that and thus your page is a 404 when there is a trailing slash in the url (since you want it without it).
https://jekyllrb.com/docs/upgrading/2-to-3/#permalinks-no-longer-automatically-add-a-trailing-slash
You may want to check which version of jekyll you have installed - you may be on 2.x and GH is now 3.x
When working locally, are you telling jekyll to use the GH pages gem? if you
don't do this you may get different behavior on GH than local. I do not do this, so I can't tell you how to do it (or if this particular issue would happen), but I do know that you should do it if you want to preview locally what you will get when serving via GH.

Related

Can Jekyll serve files when a directory of the same name exists?

I have a simple use case on a site that I am publishing with Jekyll:
I need to list values of a certain type. Let's say one type has URIs of the form .../base/typex/value. I am generating a file .../typex/value.md and Jekyll happily serves it.
I also want to serve pages listing all values. That page should be named .../base/typex or .../base/typex/ (I don't mind either way).
I cannot use the file .../base/typex/index.md to do this because in some cases, index is actually a valid value.
I am creating .../base/typex.md, but Jekyll ignores it, regardless of the permalink that I put in there that specifically has no trailing slash. Instead of serving the file, Jekyll serves the directory listing.
Is there any way I can solve this puzzle? If Jekyll had support for serving .../base/typex.md, everything would be good, but it seems as if as soon as there is a directory .../base/typex/, Jekyll simply ignores this file. Is there any workaround or configuration I can use? (And this is going to get hosted on GitHub, so I have no control over the Web server configuration.)
( https://github.com/dret/webconcepts/issues/25 has the backstory, in case anybody is interested. But the issue is fully described here, so there is no need to follow that link. )
I just tried to reproduce it with your provided repository, thanks for that!
If you create a file http-method.md in /concepts and set the permalink to
permalink: /concepts/http-method/, my local jekyll serves the page both in /concepts/http-method and /concepts/http-method/

Local Jekyll Serve/Live Site discrepancy

I am creating a jekyll blog to host on my github.io account using a theme. The problem is simple: when I run 'jekyll serve' the site generates locally as it should with no issues. However, when I push it to my_profile.github.io repository, it is breaking online.
I'm confused as to why this is happening. I found one other question here on stack: Locally building and pushing jekyll site to github pages. An answerer recommends pushing only the _site folder of jekyll that gets auto-generated. However, that didn't solve it for me.
Link to my repo if anyone wants to take a stab:
https://stackoverflow.com/questions/36377865/locally-building-and-pushing-jekyll-site-to-github-pages
Link to broken live page: https://spirited-away.github.io/
Any ideas appreciated!
Looks like you're requesting assets with http://, but serving your site on https://. Browsers don't like that. Use your browser developer tools to see the errors.
Although I can't be sure without a repo URL, you've probably got something like this set in your _config.yml:
url: http://spirited-away.github.io/
Change it to:
url: https://spirited-away.github.io/

Setting up a GitHub Pages project page. Page is up but images and main.css are not loading

Hello People of Stack Overflow,
First time setting up a project page on GitHub pages. I'm thinking I probably missed something very simple, but I have tried everything I could find, also hoping that even though this question has a high probability of being a bit idiotic that the formatting is pretty good.
The story so far...
Hosting a static site on GitHub pages. It's a project page based on a working repository. I created a gh-pages branch and pushed to this branch. That branch is now set to default and all the files are up on the repo I have looked at several questions on stack overflow that are very similar to the problem I am having but they don't seem to be quite the same.
The page is loading here
but neither the images or the CSS formatting is loading. The page was built with html, css and bootstrap.
Questions that are very like the problem:
This seems the closest: static resources not loading (rep < 10)
Maybe I need to address the root file somehow in the _config.yml? Like in this question: github pages not building (rep < 10)
Thinking the answer lies here: in the jekyll docs (rep < 10)
Avenues explored:
Created .nojykell file in the root folder, this seemed to be the best option as I don't actaully need jykell.
As another possible route, Created config.yml file
with keep_files: [img, app.js, main.css];
and then include: [img, app.js, main.css];
also added highlighter: rouge; in the 1st line, per a build error.
Jykell gave me an H10 error at one point and I installed kramdown, although that did not do anything, got the same error. This seems like an unnecessary step because I'm not using jekyll, just need a spot to serve the files already created in the interwebs.
Updated ruby
Removed ../ in front of files on the .html pages
Other things you might need to know:
File structure:
- root
- img
- .nojykell (empty)
- app.js
- index.html
- artist.html
- gallery.html
- main.css
Let me know if you have any suggestions and thanks. :)
Good to see you figured it out.
For future reference, a .nojykell wouldn't have solved the problem:
It is now possible to completely bypass Jekyll processing on GitHub Pages by creating a file named .nojekyll in the root of your pages repo and pushing it to GitHub. This should only be necessary if your site uses files or directories that start with underscores since Jekyll considers these to be special resources and does not copy them to the final site.
https://github.com/blog/572-bypassing-jekyll-on-github-pages

Jekyll-Redirect-From Redirects Not Being Applied

I'm contributing to an open source project that has its documentation built in Jekyll and hosted on Github Pages. I'm trying to add a redirect in the documentation, so I've forked it and am using jekyll-redirect-from in the fork. However, the redirect simply doesn't seem to be applied. That is, the jekyll build folder doesn't contain any static file to hold the <meta redirect> html that jekyll-redirect-from is supposed to generate. Instead, when I visite the URI that's supposed to be redirected, I just get a 404.
I've followed all the steps in the jekyll-redirect-from docs, including:
Adding jekyll-redirect-from to the Gemfile (code)
Adding it to my _config.yml file (code)
Adding the redirect_from key to my page's front matter (code)
I'm using jekyll 2.5.0 and jekyll-redirect-from 0.8.0 (the full gemfile is linked above). I'm building the project with bundler (using bundle exec jekyll serve), which is how the project's always been built.
Jekyll isn't showing any errors—the static file that should hold the redirect simply doesn't show up.
I can't for the life of me figure out the problem. Maybe I'm overlooking something obvious, or maybe there's some sort of subtle incompatibility in my dependencies?
D'oh. The issue was that the safe option needed to be set to false for the plugin to run. This tripped me up because I know Github Pages sets safe to false as well, and yet jekyll-redirect-from generally runs there. But that appears to be because GH Pages has made an explicit exception to allow it.
My issue was that I had:
redirect_from: /a/path/
redirect_from: /other/path
And repeated directives don't work like that in YAML.
Instead, it should be:
redirect_from:
- /a/path/
- /other/path

jekyll pretty permalinks give me WEBrick error

I am developing my blog in Jekyll (3.0.0 beta), currently on localhost,
When i am trying to implement the pretty permalink and i try to visit a post it shows a WEBrick error.
If i apply the /:year/:month/:day/:title.html it works fine do you have a clue why isn't it working with pretty permalinks?
This is the error I get:
/2015/08/03/are-permas-working.html' not found. WEBrick/1.3.1 (Ruby/2.1.6/2015-04-13) at localhost:4000
Once you set Jekyll permalinks to pretty in _config.yml like so:
permalink : pretty
... and restart your WEBrick server (a restart of the server instance using jekyll serve or bundle exec jekyll serve [if following GitHub] is needed for the new values to take effect, your permalinks will no longer be in the format of YYYY/MM/DD/title-slug.html since they are now "pretty". The new format for your links will be /:categories/:year/:month/:day/:title/. This is in accordance to the format determined by the pretty variable as defined here in the documentation.
What this means for you is that your original link for the 'Are permas working' post is no longer at localhost:4000/2015/08/03/are-permas-working.html, rather they are now at localhost:4000/2015/08/03/are-permas-working/ since you don't have a category defined.
You're experiencing this error because after you've made the change and restarted your server you most likely did not navigate to the post from your homepage (which will have that new link to point to the post), rather you just refreshed the page on your browser, which will throw a 404 since the page is no longer there.
Bonus, Jekyll makes posts pretty by creating folders 2015 -> 08 -> 03, and then a folder for that specific post, with an index.html inside it.
Also, if you wanted "pretty-fied" links that don't have the dates there, you'll need to manually specify that using this:
permalink: "/:categories/:title"
This ensure will hide the .html extension and also get rid of date values.
EDIT: From the comments I stated that using /:title for permalinks might not work since there are conflicts with non-post pages, I stand corrected. If you wanted short permalinks like user.github.io/title-of-blog-post/ you would just need to set permalink : /:title and you're good to go. However, if you have non-post pages such as an about page, a credits page, you should explicitly set permalinks on those pages to be /about and /credits on the YAML frontmatter to avoid the edge case of also having a blog post with the title about and accidentally overwriting the non-post page.