How to set up permalinks with variables in jekyll? - jekyll

I'm trying to setup jekyll so that it will automatically create permalinks for new posts but it's not working.
What I did is setting a variable in the _config.yml like this:
permalink: /:title/
then, in a loop of post previews on the homepage I created a link like this:
Read More
Expecting the output to be something like.
Read More
and instead I'm getting this:
Read More
which if I click gives a 404 Not Found error.
What am I doing wrong?
For more info here is the github repo.
Thanks!
Matteo

As #David Jaquel suggested I solved by using
{{ site.baseurl }}{{ post.url }}

Related

Jekyll website with Staticrypt protected post, Where to put the encrypted.html?

I'm using Jekyll for my blog. I want to protect some blog post with a password and I've decided to use Staticrypt.
I can encrypt the index.htmlpage of one of my blog post with the Staticryp CLI and my custom password_template.html. It outputs a index_encrypted.html.
My question is: Where do I put the index_encrypted.html? I can't add it to the _site since Jekyll return the build to default everytime I serve it.
I tried adding the index_encrypted.html to the _includes folder and calling the page from the .md post like this:
{% include index_encrypted.html %} but this just break the page.
Thank you!
I figured out how to do it.
Here's what I did:
Put the index_encrypted.html in _includes and _layouts
Add a permalink: /index_encrypted.html in front matter of the .md post you're targetting.
Add a layout: index_encrypted in front matter of the .md post you're targetting.
Delete the whole markdown content of the .md post.
Voila!
You front matter should look like this:
---
title:
date:
tags:
description:
layout: index_encrypted
permalink: "/index_encrypted.html"
---
Edit: Make sure to create a copy of your .md post for later use.

How to fix Jekyll Baseurl problems

I'm making a theme for Jekyll, and I've hit a problem where the site only serves to localhost:4000, and when I add a baseurl, it ignores it, although the command line output says it is serving it to localhost:4000/baseurl/. The theme is on GitHub here.
Any help much appreciated!
Should be fixed when you use {{ page.url | prepend: site.baseurl }}.
It was a Windows problem. See https://github.com/forgenst/jekyll-statuspage/issues/3

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!"

Is there a way to get the full path of the markdown post in jekyll?

I created a blog just for my personal use. Just to organize my own notes.
Unlike a proper blog where after you write the post you are usually done. I will be editing these post frequently, so in the footer I want to have the following:
sublime /path/to/_posts/markdown-post.md
So that I copy it and paste it in my terminal.
So is there a way to get all that information dynamically. Or at least the full markdown file name (I could hard code the path myself)
{{ site.source }} will give you absolute path to your site root.
{{ page.path }} will give you page path relative to site root.
Finally subl {{ site.source }}/{{ page.path }} will do the trick.

Jekyll paginator generates no pages

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.