Jekyll paginator generates no pages - html

I'm having an issue with pagination in Jekyll. It doesn't seem like the paginator liquid tag is doing anything at all. Whenever i replace my for loop on my main index.html page,
{% for post in site.posts %}
with
{% for post in paginator.posts %}
no posts will appear (they appear properly with the first tag).
My _config.yml file does have the following added to it:
paginate: 1
paginate_path: "page:num"
If I try to use another paginator tag such as {{ paginator.total_posts }}, nothing appears.
I'm trying this by deploying locally, but the final pages go onto github pages. Can anybody tell me why it doesn't seem like the paginator tag is working?

The issue here wasn't with the paginator tag, it was with the paginate tag within the _config.yml file. I had forked this from Jekyll Bootstrap, which has a variable called JB within the _config file. When I added the paginate tag, I added it, but I added it as a sub-variable to JB instead of as a top-level variable. Removing the indentation on the paginate variable fixed this issue

Jekyll 3.0 deprecates pagination, so
gems: [jekyll-paginate]
must be added to _config.yml to get pagination to work again.
However, if you previously added
safe: true
to your _config.yml, like I did, no gems will be loaded–including jekyll-paginate! Removing safe: true and adding gems: [jekyll-paginate] will allow Jekyll 3.0 to perform pagination again.

Related

Jekyll site.categories is empty

I have tried this code {{site.categories | inspect}} in default.html, but it returns empty space like this {}.
My post has a front matter that includes categories: apple.
What have I missed?
oh i found..
My jekyll theme post was referenced from 'docs' folder, but jekyll said every posts should be placed in _post folder. so jekyll site variable could not read categories of posts in docs folder.

Could not get disqus to work with jekyll and git pages

I am using Github Pages and Jekyll. I added the Disqus configuration but it could not appear on the posts.
I added disqus.html in the _includes directory. and added my disqus shortname into _config.yml.
Called {% include disqus.html %} from _layout/post.html.
Tried the comment:true option in the markdown files as well.
You may view my work at:
https://github.com/motleis/weekActivities
Thank you for your help.
EDIT: So far, I tried to converge the problem and noticed that {% if site.disqus %} is not evaluated to true. The only thing I can think of is filling the 'disqus' parameter in the _config.yml.
Any other things?
Finally I figured this out!!
"put your short-name inside quotation marks!"

Jekyll: parse pages without front matter

As far as I gather, Jekyll parses an included page through the templating stage if and only if it finds a YAML header / front matter. Otherwise it just copies it. Is there a way to force Jekyll to parse an included file without a front matter?
The rule of thumb is that Jekyll will not parse files without front matter.
However... there is a work-around. You can create an index.html file in the _includes directory without front matter. The Liquid in this file will be interpreted by Jekyll. You can render this include anywhere using:
{% include index.html %}
This solution is perfect for rendering HTML pages within a Jekyll context (without having the front matter requirement), especially when you want to reuse them. This could be useful for rendering a preview AND showing the code in a code block on another page. The include could be written in a layout file or in an index.md file.
Note that the included filename can be a variable (https://jekyllrb.com/docs/includes/):
{% if page.my_variable %}
{% include {{ page.my_variable }} %}
{% endif %}
Also note that if you want to show Liquid examples in this code, you should use:
{% raw %} ... Liquid example ... {% endraw %}
If you want a solution work-around for your specific situation, you should share your repository and explain your use case.

Jekyll: liquid tags shown when hosted on GitHub

I'm just getting started with Jekyll and I managed to do some cool stuff locally - i.e. when I locally serve the page and open it on my browser, everything works fine.
However when I pushed everything on GitHub, I see the actual liquid tags on my pages, and not what they're supposed to stand for.
I'm not even sure of how I can debug this, as locally everything looks fine. I made sure my local and remote repositories are synced.
Thanks!
ADDITIONAL INFORMATION - HTML and CSS are rendered properly, and the Jekyll frontmatter seems to be doing its job by pointing to the correct layouts. It's only the liquid tags that don't seem to be working. I did have liquid tags working just fine on initial tests I did directly on the remote repository (very basic stuff like showing titles, dates, etc), but after pushing things I wrote (and successfully tested) locally, it seems like they are not being correctly interpreted anymore.
In your three _layouts, add a <meta charset="UTF-8"> just after the opening <head>.
In _layouts/default.html and _layouts/timeline.html change {{ page.content }} to {{ content }}.
In _includes/timeline.html remove {{ page.content | markdownify }}.

Jekyll plugin to handle categories doesn't work on GitHub

I've copied the Jekyll plugin to generate Category pages using an official source (https://github.com/recurser/jekyll-plugins) into my Github repository and it doesn't work, I keep on getting a 404 page. That said if I test on my local machine both in the Jekyll server and in the _site directory it works. Any ideas?
GitHub Pages does not support most plug-ins. They don't want anything crazy going on behind the scenes.
Here's how I do categories with Github Pages. It is not wholly automatic, as it requires a separate .html file for each category you want to set up. But it works without any plugins or wizardry on Github Pages.
Create a categoryname.html file in your root directory. For example, hardware.html for a Hardware category. Run a for loop on all of the site's posts and check the post.category
<div class="posts">
{% for post in site.posts %}
{% assign author = site.authors[post.author] %}
{{ author.display_name }}
{% if post.category == 'Hardware' %}
<div class="post">
<h1 class="post-title">
{{ post.title }}
</h1>
{{ post.content }}
</div>
{% endif %}
{% endfor %}
</div>
In your posts, you would use the YAML header to add the category to the post. Like the code below:
---
layout: post
title: How We Built a Hardware Product
author: Author Name
category: Hardware
---
That should do it. It'll create a /hardware/ page that will include all of your posts with the Hardware category. Make sure you're case-sensitive on your YAML and category names (hardware != Hardware and category != Category).
Another possible solution:
If you don't want to generate your site locally and push the created HTML files to GitHub (like David Jacquel suggested in his answer), you can create one single page with all categories.
Check out this answer:
An easy way to support tags in a jekyll blog
(Note: I'm using tags instead of categories there, but both work exactly the same way in Jekyll as far as I know. So you can just take my code and replace site.tags by site.categories)
I admit, one page per category looks nicer, but my solution has the advantage that it works on Github Pages (because it's just vanilla Liquid, no plugin).
EDIT:
In the meantime, I wrote a blog post how to make separate pages per category without using a plugin:
Separate pages per tag/category with Jekyll (without plugins)
Github pages only support a small number of Jekyll plugins.
If you want to use your plugins, you'll have to generate your site locally and push it on github pages. If you do this, add a .nojekyll file at the root of your repository to tell github to not process you files.