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
Related
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.
I would like all posts and pages on my Jekyll site to have the same link structure: example.com/my-title, regardless of the directory structure I use to store my files.
Looking at the documentation it seems like I should be able to implement this by putting the following line in my _config.yml:
permalink: /:title.
This almost works. All posts (in the _posts/ directory) get the correct URL. And all pages in my site's home directory also get the correct url. However, pages that are in subdirectories still have the directory path prefixed to the url. For example, if I have a page pages/cats/my-cat.md the URL is example.com/pages/cats/my-cat, instead of what I want (example.com/my-cat). If I set the permalink for that page directly in the front matter as /my-cat I get the desired outcome, but I'd rather not do this on every page.
Is it possible to remove the path from all page URLs?
I see a number of other questions about Jekyll permalinks but nothing that addresses this exactly. This answer from 2013 says that pages will "always remain relative path" but that's fairly old, and also seemed like a throwaway assertion rather than an evidence-backed claim.
You can use Jekyll defaults to apply fallback front matter for files based on a type and/or path. It has the same effect as setting the front matter inside each file. Here's how you could apply that permalink to all pages:
_config.yml:
defaults:
- scope:
path: ''
type: pages
values:
permalink: /:title
It's also a great way to set other common fields, e.g. layout.
Official documentation for further details: https://jekyllrb.com/docs/configuration/front-matter-defaults/
I apologize because I think I'm missing something very obvious here, but when I make sub-categories in the Jekyll hierarchy this is how I've done it so far.
My root directory being karrots_page, I'll have a structure like this
karrots_page/articles
and within the questions directory, I'll have a few markdown pages like
articles.md
happiness-is.md
boring-questions.md
fun-questions.md and boring-questions.md will have front matter like
---
layout: page
title: Happiness is?!
permalink: /happiness-is/
parent: articles
---
and the articles.md named after the directory it's in /karrots_page/articles will have a front matter like this
---
layout: page
title: articles
permalink: /articles/
has_children: true
---
and although that works, once I am within one of the article pages I can't get the link at the top to navigate back to the articles.md the main page, I just get a 404 when I click this link
The other strange thing is I have this all set up and working on another site in which there is a page that goes two levels down /karrots_notes/questions/1000-questions where every page directly nested in the /questions directory can successfully navigate back to the /questions directory with the top link, but when you go deeper down into a page in 1000-questions directory, when you click the top link to go back to the list of 1000-questions pages, it just takes you to the homepage of the site.
on top of that when I add the whole of the /questions/ directory to the site where the navigation links don't work, all of the sudden the navigation links do work for my articles directory.
I have a feeling I'm not doing something right with the markdown front matter, but I'm not sure what.
In my site settings, I have the default
baseurl: ""
My site is a blog and my domain name already includes the word blog (blog.example.com), but when I add posts to my site they end up with the path /blog/yyyy-mm-dd/title-here.
How can I get them to be put in /yyyy-mm-dd/title-here instead (without the initial /blog path)?
I am using GitHub pages to serve my site, so I cannot use mod_rewrite.
The baseurlsetting is not relevant for this.
Adding permalink: :year/:month/:day/:title to _config.yml gives the desired permalink style.
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: /