thomasvaeth/trophy-jekyll

Categories and Images

Closed this issue ยท 9 comments

Hi, Thomas~ Thanks for your contribution to the theme. Currently, I am having the same issue that all the category pages return a 404 page. And all the images cannot be uploaded. I put them in a img folder under assets and use /assets/img/1.png. I tried the solutions that you've discussed on other issues but they just do not work. Strange is, when I tested it on localhost:4000 using Jekyll Serve --watch --baseurl " ", it worked perfectly fine~ Do you have any idea why these were happening? Thanks again~

image problem solved, but category pages still return a 404 :(

https://github.com/GrietjeWong/Myweb/tree/gh-pages/_site/category They're right in your _site folder, so I don't know why it's coming up 404. It's not for me.

First of all, thanks for the great theme. I have the exact same issue here, 404 return from category pages. It also works perfectly for me offline after building with sudo bundle exec jekyll serve.

However, after pushing the changes, the categories doesn't work on the live githubpages, exactly like @GrietjeWong. I tried to manually create a _categories folder like https://github.com/thomasvaeth/trophy-jekyll/tree/development/_categories as suggested, but it didn't fix the issue.

TL;DR: it's all perfect in the "local" Jekyll generated version inside (_sites folder).. but when it goes live, the page goes broken, even if manually creating a /_category with .html files inside folder.

Here's my repo: https://github.com/jacobsalzberg/db/tree/gh-pages
(I have removed _site from .gitignore)

@jacobsalzberg So your repo is called db. You need to only put the contents of the site folder into the gh-pages branch (not the whole entire build). If you look at my development branch it has my whole build, then my gh-pages branch only has the content from _site. I'm guessing this is why you're 404ing.

Github allows you to have one repo called jacobsalzberg.github.io where you can just have all build on the master branch and Github automatically just looks for the _site folder. My main repo https://github.com/thomasvaeth/thomasvaeth.github.io and my girlfriend's https://github.com/melmilloway/melmilloway.github.io as an example.

But this theme was updated last weekend, so categories are generated automatically if you haven't gotten too far into editing it.

Thank you for your reply @thomasvaeth, that's very kind of you and I have learned a lot from it. My knowledge in front-end development is very limited.. So I bumped my head against the wall until I finally came out with a work-around on my end.
I was editing my post just as you replied (trying to help both me and @GrietjeWong as we have/had the same issue).

Here is what fixed it for me: (TL;DR: It's was related to category.html being missing in /_includes/ folder, adding include: ["_categories"] on _config.yml and adding a _categories folder with .html files inside for each category)

The master branch is a bit "outdated"(?) it seems..
https://github.com/thomasvaeth/trophy-jekyll/tree/master

If you check the differences between
https://github.com/thomasvaeth/trophy-jekyll and https://github.com/thomasvaeth/trophy-jekyll/tree/development you should see why our page wasn't working properly

Please Note: I'm a newbie on ruby/jekyll/etc.. this is mostly a work-around, but it worked perfectly (I'm sorry if it's not using the right way to fix it):

So here's the (dumb?) fix - supposing you've cloned from master

i) ADD [include]: ["_categories"] inside your _config_yml file below # Build Settings

example: https://github.com/jacobsalzberg/db/blob/gh-pages/_config.yml

ii) add a category.html like this one, inside _includes (copied it from thomas dev page)
https://github.com/jacobsalzberg/db/blob/gh-pages/_includes/category.html

iii) ADD a _categories folder, with a single .html file inside it for each category, name after them and follow this pattern:

---
layout: default
title: Personal
description:
permalink: /category/personal/
---
{% include category.html %}

example: https://github.com/jacobsalzberg/db/tree/gh-pages/_categories

iv) That fixed it for me. After reading what @thomasvaeth posted I guess that's a "bad" fix though..

@thomasvaeth Thanks again for your explanationand beautiful theme, it's a masterpiece. I have no clue whatsoever why my solution/workaround fixed-it though.

The way you explained was the old way of doing it. But there is now a _plugins folder that generates all the categories for you automatically. I would just pull master again if you haven't done too much editing to the theme.

Sorry to rely you late~@thomasvaeth Thank you Thomas, very much to your suggestion on our shared issue~( @jacobsalzberg's and mine)

Thank you guys for your lovely solutions~ That fixed for me by following @jacobsalzberg 's example.

Below are my opinions but may not be right since I'm quite new on using Jekyll to build a website:p

For me, there might be some problems with the category generator: as it generated a folder with category name and under the folder is index.html.

When I looked at the like on url on 404 pages, it's like /../category/category-name

Jekyll serve can find the path and have category-name.html on _site/category

But when we uploaded them to online, GitHub server cannot find the correct path for category/category-name

Very much appreciated for your great job~ i love the theme~

Long read warning, Just trying to help -- there's a TL;DR version at the end

This issue gave me a huge headache so I really want to try to help you, sorry if I'm being nosey here. Thomas of course might have a better answer, but I think I can help, as I think I really understand how this works now.

Adding to what Thomas' replied to me (concerning only needing to add the _site folder to the gh-pages branch):

There are two kind of jekyll themes:

  1. Jekyll themes without plugins (or with plugins allowed by github);
  2. Jekyll themes with plugins;

Thomas' theme used to be plugin free as he said.. but not it has plugins!

How it works:

For themes without plugins, you can push the whole build into your repository and just by adding your markdown posts into your _posts folder, github will build and deploy for you (as for example, doing jekyll build locally). The only thing you need to do is to manually add the categories as I described, but that's only if you add new ones.

For themes with custom plugins, you have to build the site at your computer (sudo bundle exec jekyll build for me) and then manually commit the files inside _sites to your gh-pages branch (and if you want, commit the whole build to another branch, just to keep the code open).

As Thomas' theme now has a plugin to handle the categories, they'll only be built locally (by jekyll build). That's why it works at your computer, because it's only instancing _site folder. If you deploy the whole build to github, github itself will try to build it as it supports Jekyll nativelly, so it will ignore the plugins, which means it will ignore the plugin that makes the categories.

So either you revert to how the theme was before, just like I did on the explanation I posted above (so github manages everything... aside from having to manually add the categories in single html files.. all I have to do now is add the posts and it gets instantly deployed) or you use the current version (with plugins), build it manually on console and upload it every single time.

TL;DR VERSION

To sum it up, you have two options:

a) revert to a version with modified _config.yml (that commits the categories you created at _categories folder), manually add _categories and add html files for each one, deploy it to github - all you have to do now is add the posts directly to github and it will build your blog (no need to jekyll build or serve ever again);
or
b) clone from master, build the site locally every time with jekyll build and deploy _site into gh-pages branch. Optional: clone the build to a master branch, just to share the code;

I'm going with "a" (previous build) as it's a lot faster.. I love github being able to build the site by itself, I can even post from my cellphone if needed with a markdown editor.
The only problem is it there are new updates to the theme, so it might be a bit of an issue to 'catch up' and implement them.

Anyhow, here's more info:

I hope it helped and I'm sorry if I wrote too much, really trying to help.

@jacobsalzberg Thank you so so much for your detailed guide! I was also banging my head for days trying to solve the same issue you had. I dug into every single file to catch a bug without any success, and I was getting more and more resentful that the Github Pages platform restricts what can be built for security reasons. Your solution worked brilliantly. Thank you so much!