Changing Jekyll site structure - jekyll

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.

Related

Set a global permalink in Jekyll without the path?

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/

Why are jekyll pages in subfolders not using my theme

I am using Jekyll to create a website on GitHub Pages. I have a _config.yml file with the following contents (this is the entire file):
theme: jekyll-theme-leap-day
collections:
tutorials:
output: true
I have a few dozen pages in my root folder, and a _tutorials folder which contains about 10 more pages. If it matters, all of my pages are MarkDown (.md extension).
All pages in my root have the proper styling (one of GitHub's built-in themes "Leap Day"). However, all of my subpages have a white background and are left-justified - it seems the theme is not applying there.
The only front matter in any of my pages is where I either specify the title: or (both in the pages in the root and subfolders).
Is there some setting I have to place in my _config.yml to tell the pages in _tutorial to use the same theme as the pages in my root folder? Do I need to put some Front Matter on each page to have it use the theme?
I tried adding the theme explicitly under the tutorials: section in my _config.yml but my tutorial pages still didn't use the theme.
Each theme comes with a specific set of layouts, chances are that your posts aren't using any of the new layout themes, so you need to check if them have a layout key in front natter specifying which layout to use, and change it to make your posts use a specific layout, or define a default layout to use when no layout key is present in posts adding a default value in _config.yml.
Update
Add the default layout to all of your pages in _config.yml:
defaults:
- scope:
path: ""
values:
layout: default
That should fix the issue.

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

How do I get a custom Jekyll permalink style scoped to just some posts (ie blog posts)?

I'd like blog posts on my Jekyll site to follow a specific URL convention. I'd like to avoid having permalinks even in the frontmatter. I'd prefer to specify my style in one place and never have to think about it again.
In _config.yaml you can specify a custom permalink style as follows:
permalink: /blog/:year/:month/:day/:title/
And posts will have a default permalink that looks something like /blog/2015/01/24/some-title/ (assuming 01-24-2015 publish date).
However, I'd like to scope this only to our blog directory. So I tried to use defaults in `_config.yaml' as specified in the Jekyll docs
defaults:
-
scope:
path: "blog"
type: "posts"
values:
permalink: /blog/:year/:month/:title/
Unfortunately, the permalink for my test post is literally http://localhost:4000/blog/:year/:month/:title
Why don't defaults behave the same way as the root permalink? Is there another way to accomplish what I want?
I'm hoping to do this without a custom plugin, as we're using GH pages and plugin options are limitted.
i had the same issue with version 2.4.0. i upgraded using
gem update jekyll
and it updated to 2.5.3. fixed my issue.

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