GitHub Pages - frontmatter causes page to break - jekyll

I am publishing pages from my /docs folder as per https://github.com/blog/2228-simpler-github-pages-publishing
If I include this front matter on a page, the build breaks.
---
layout: page
title: "Help Page"
permalink: /help
---
The page is built but only contains the data from the <body> element. No headers, no stylesheet, just garbled HTML. The same occurs if I use layout: post.
If I removed the line layout: page then everything works.
According to the GitHub documentation - https://help.github.com/articles/configuring-jekyll/ - I should be able to use this frontmatter in my pages.
What blindingly obvious thing have I missed?

The "slate" theme only has a "default" layout.
So switching to layout: default fixed the issues.

Related

Github Pages Build of Jekyll site is missing pages

I'm trying to use Github pages with Jekyll. Most of my pages are displayed as expected, but others (that I can see in the local build) do not show on the Github pages build.
The pages that do work are in the _pages folder with their permalinks set in the front matter. Like this
---
type: page
permalink: /about/
layout: default
---
The pages that don't work are in a folder _projects with similar, but slightly different front matters
---
permalink: /projects/foo
layout: post
---
When I try to access foo.com/projects/foo/ it gives me error 404, but foo.com/about/ works as expected. There are no front matter defaults, so what you see is what is there.
I found my solution in the similar questions as I was writing this, but couldn't with a google search.
Github Pages didn't like having the permalinks for _projects in the format /projects/foo/, but /projects/foo.html works like a charm.

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>

Why is default layout not being applied to pages?

I am trying to use Github Pages and Jekyll for the first time. I created a repo and followed the instructions to set it up.
I am having trouble getting the default layout to work. A layout file: _layouts/default.html exists in the repository and my _config.yml looks like:
defaults:
-
scope:
path: ''
values:
layout: 'default'
Even with the setting above, the pages are not getting the default layout applied. See the Github Repositry and My github page that currently shows:
Look in _config.yml, why is default layout not being applied??
Without any layout.
What am I missing?
All your pages must have a front matter (event empty) if you want Jekyll to parse them.
Without a front matter, your pages are just copied like static files.
So, your index.html must be :
---
---
Look in _config.yml, why is default layout not being applied ?
default layout is them applied.

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

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: /