When I was using Jekyll 2.x, the folder structure within _blog was like this:
/blog/post1/index.html
/blog/post2/index.html
But since upgrading it's like this:
/blog/post1.html
/blog/post2.html
So although the permalink setting in _config.yml is permalink: /blog/:title, all the links I use are broken. What's going on? Is there a setting I'm missing?
Permalink config should be permalink: /blog/:title/ with a trailing slash.
Related
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.
md file with a link to Folder/file.md
When jekyll generates the index the link to the file is still folder/file.md and so doesn't connect to the generated file.html. Can jekyll replace links in markdown with their corresponding html files?
I really want to to maintain my folder structure (7 or so subfolders, each with 3 markdown files).
The answer since December 2016 is to use the jekyll-relative-links plugin.
It is a white-listed plugin if you are hosting on GitHub pages so you probably already have it.
If you are not using GitHub pages you will need the following installation instructions (from the README):
1.Add the following to your site's Gemfile:
gem 'jekyll-relative-links'
2.Add the following to your site's config file:
gems:
- jekyll-relative-links
The tag you're looking for is {% link %} and it arrived in 2016.
If you had {% link _funkyCollection/banjo.md %} it would generate the right path to the output file funkyCollection/banjo.html, or funkyCollection/banjo/index.html, or whatever, wherever it ends up being.
This is what I did to solve this problem with jekyll 3.8.5.
For link in root directory: /file.md
---
layout: page
title: Root File
permalink: /file/
---
This file is in root directory.
For link in subdirectory: /folder/file.md
---
layout: page
title: SubDir File
permalink: /folder/file/
---
This file is in sub-directory.
Now to link these file:
[Root File]({{site.baseurl}}/file/))
[Sub Dir File]({{site.baseurl}}/folder/file/)
Hope this helps someone.
i've written a simple plugin to solve this. put this in _plugins/, and make links refer to the *.md files (so github rendering linking works); if you build it with jekyll (when you are able to run plugins) the links are changed to *.html. since github doesn't run plugins, this isn't applied.
module ChangeLocalMdLinksToHtml
class Generator < Jekyll::Generator
def generate(site)
site.pages.each { |p| rewrite_links(site, p) }
end
def rewrite_links(site, page)
page.content = page.content.gsub(/(\[[^\]]*\]\([^:\)]*)\.md\)/, '\1.html)')
end
end
end
it's not perfect (i'm sure you could fool the regex) but it has been good enough for my purpose.
A Folder/file.md page will result in creation of a _site/Folder/file.html page.
So when your link to this page it's [Link to page]({{site.baseurl}}/Folder/file.html) not [Link to page]({{site.baseurl}}/Folder/file.md).
Jekyll will never rewrite file.md to file.html in url. So you have to set your links targets yourself to the resulting page.url which is usually a html file but can be css, je, json, ...
If you use permalink: /folder/folder/ in any file.md, it will generate a /folder/folder/index.html file which can be reached with [Link to page]({{site.baseurl}}/folder/folder/)
I've run into this and written a basic Jekyll/Kramdown plugin. It's less likely to break than the regular expression approach.
As long as your link doesn't start with http:// or something like it, and ends with .md, it will convert links to their lowercased and hyphenated names.
Of course, you could always modify the behavior to fit your needs.
using jekyll 2.0.3,
I initially configured _config.yml with
markdown: kramdown
and I was able to add a table of contents as follows, in my example.md:
---
layout: page
title: Sample
---
{:toc}
## section 1
## section 2
however, I switched to redcarpet, see _config.yml:
markdown: redcarpet
redcarpet:
extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "strikethrough", "superscript", "with_toc_data"]
and now {:toc:} does not work.
The documentation of redcarpet v2.2.2 (used by jekyll 2.0.3):
https://github.com/vmg/redcarpet/blob/v2.2.2/README.markdown#and-its-like-really-simple-to-use
mentions :with_toc_data, but I don't where/how to use this.
how can i display the table of contents using redcarpet?
The problem here is that :with_toc_data is an option for an instance of the redcarpet renderer, and not a configuration extension.
Unfortunately, Jekyll doesn't seem to expose this renderer option, so I don't think you'll be able to use it. The docs say:
no renderer options aside from smart can be specified in Jekyll.
But you can use a table of contents jekyll plugin instead. A quick search returns a number of available options, and one is linked from the official Jekyll site.
Maybe this should work. Mention this in the _config.yml file.
markdown: redcarpet
redcarpet:
extensions: [with_toc_data]
I'm using markdown on my blog along with JQuery and a js file. This is how it looks like.
Here is the detailed guide on how to do it - Jekyll TOC
I want to add collections to my Jekyll site. In my _config.yml file I set output: true:
collections:
faq:
output: true
In my source folder I added _faq folder and created a file named 1.md in it.
When I generate the site I can see my document at http://localhost:4000/faq/1.html. But when I customize the permalink for this document and add permalink: /faq/1 in its YAML front-matter, it doesn't display at http://localhost:4000/faq/1 and downloads to the computer instead.
Is there any way to customize permalinks for documents in Jekyll collections (to show without .html extension)?
The permalink should be permalink: /faq/1/, then it works.
Permalink should be permalink: /faq/:path/
That will set the correct relative path for all files and subfolders of that collection and drop the .html suffix.
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".