How to have Jekyll-Bootstrap not put "index.html" in the navigation - jekyll

I'm a happy Jekyllbootstrap user, however the index.md template is compiled to index.html. This is expected, but for me undesired behaviour.
When the navigation links to the homepage it uses index.html on the anchor. I can get around this using an nginx redirect, but I don't want to have any links on my site that I'm "fixing" using 301 redirects. I'd like it to generate the correct link in the first place.
So to be clear. I don't want jekyll to ever link to index.html but instead link to /.

You can modify the variable HOME_PATH in _includes/JB/setup. By default it is {% assign HOME_PATH = "/" %}.

I found the answer to this. I had to set the following at the top of my index.md file:
---
layout: page
title: Home
group: navigation
permalink: /
---
The key part here being permalink: /

Related

Nav bar not showing up on permalink Jekyll site

I've been toying around with a GH Pages Jekyll site. I took an HTML static site and changed the location for the stylesheet and the text/CSS.
Everything works correctly on my index.html page. However, on the other pages, the mobile/half-sized desktop navbar doesn't appear. The difference being I used a permalink to get navigate to those other pages (/categories/ instead of /categories.html).
I played around with the config file tried changing the
permalink: /:categories/:title/
to
permalink: /:categories/:title.html
Which gives the right filename, but it didn't address the navbar.
The only way I could fix the landing pages for the categories would be to change the links in the default.html. In this example the second item on the list works and the other doesn't.
<nav id="nav">
Doesn't work
Does work
</nav>
My goal is to have permalinks. So I can seamlessly navigate from the landing page to the categories and the blog posts.
This is my GitHub repository: https://github.com/Thor-DraperJr/Thor-DraperJr.github.io
Thanks for the advice!
It turns out that the css only was written to apply to www.baseurl.com/page
I changed the permalink in the _config.yml
permalink: /:title
This meant that each page and post would only show up one level past the root url.

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.

Permalink to External Site with YAML Front Matter

Is it possible to set a permalink to an external site within YAML front matter? I am currently using Jekyll, and I am not finding any information using my Google-Fu.
---
layout: full-width
title: TEST
permalink: https://somethingexternal.example
---
Can permalink break out of it's context and head to somethingexternal? I just want the TEST link to appear on the home page, but when clicked, to go to somethingexternal.example.
[edit]: What happens is that it prepends the webroot to the site, which is the expected behavior. So it ends up like:
mysite.blah/https://somethingexternal...
I just need to break out of it, so that it only goes to the external site. I don't know if permalink can do that, though.
Using permalinks for an external link won't work, permalinks aren't for that.
What you are looking for is to define a custom URL in front matter and then access it's value from the page like this:
---
othersite: http://example.com
---
visit other site

Jekyll link within page

I'm using Jekyll on Github, and I wonder whether there's a way to link to a section within a page. Say I have a section like
## Section 1 ##
section content
and later in the same page I want to link to this section. I've found how to link to another page within the blog and do footnotes, but not this.
As a note, I use markdown: kramdown in my _config.yml
kramdown supports the automatic generation of header IDs if the option
auto_ids is set to true (which is the default). This is done by
converting the untransformed, i.e. plain, header text
So in the above example ## Section 1 ##, it would generate the following id: id="section-1", then the anchor is linked to via the A element:
Section One
Or in plain kramdown/markdown: [Section 1](#section-1)
It seems that this has been changed to #heading-section-1 (checking on Jekyll 3.7.3 right now).
As a way to figure this out on your own, you can inspect the element and see the id being used on the rendered page.
I found a nice repository that helps add anchors to all headers in three simple steps.
From docs:
Download the anchor_headings.html file from the master branch
Toss that file in your _includes folder
Where you typically would put {{ content }} in your layout,
you would instead use this Liquid tag to output your page's content:
{% include anchor_headings.html html=content anchorBody="#" %}
As result you will see:
Which is easy to customize.
If the section of the page you want to jump to is not a section heading, then this accepted answer didn't work for me. The following worked for me:
[jump](#final-solution)
<div id="final-solution"></div>

How can I change the blog post URL of a Jekyll website?

I'm using Jekyll to create a blog/website. I have it setup so that it displays the URLs like this:
http://example.com/blog/title-of-post
I want to modify it to change the the "blog" part of the URL. For example:
http://example.com/writing/title-of-post
How can I do this?
You can do this by setting the permalink in your _config.yml file. For example:
permalink: /writing/:title
Note that this assumes that jekyll is building your entire site and isn't just powering the "blog" directory. If jekyll is only writing to your "blog" directory, then all you would need to do is rename that to "writing".