Closed thomaswitt closed 1 year ago
This issue has been automatically marked as stale because it has not been commented on for at least two months.
The resources of the Jekyll team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master
/main
branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.
This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.
It appears Jekyll-SEO respects the permalink structure as set in the frontmatter. In my site I have set the following in the frontmatter defaults for the paths where my HTML files reside:
scope:
path: ""
values:
layout: "default"
permalink: :path/:basename
This removes all file extensions for those paths when a frontmatter is defined. It also makes sure things like page.url are set correctly, so all your links on your website will immediatly redirect to the URL without the HTML, instead of having to redirect users.
Relevant documentation: https://jekyllrb.com/docs/permalinks/
EDIT: Just to clarify, what I'm saying is setting the permalink structure correctly in jekyll itself appears to resolve this issue, and should be done anyway for other reasons. I think this issue can be closed based on this.
@FranseFrikandel – Thanks for the idea. That doesn't seem to be without side effects. I get the following error message when using your defaults:
Liquid Exception: The URL template doesn't have basename keys. Check your permalink template! raise NoMethodError, ^^^^^ in website/_layouts/post.html from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/url.rb:96:in
gsub'
from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/url.rb:96:in generate_url_from_drop' from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/url.rb:62:in
generate_url'
from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/url.rb:46:in generated_permalink' from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/url.rb:39:in
to_s'
from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/document.rb:247:in url' from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/drops/drop.rb:65:in
block in delegate_method'
from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/drops/drop.rb:128:in public_send' from /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jekyll-4.2.2/lib/jekyll/drops/drop.rb:128:in
[]'`
The website I did this on didn't actually have any blog posts and was only static pages. It indeed breaks once you add a blog post.
The Jekyll documentation actually says setting the URL structure for pages in frontmatter defaults doesnt work... But it appears to be working fine for me. Limiting the front matter scope to be just pages by adding type: pages
to the scope appears to fix your issue. You would have to add another default for posts where you use :title
instead of :basename
and it should work everywhere.
Sounds like a potential solution. I'll look into it. Thanks for your ideas, @FranseFrikandel.
I'd propose to make the .html ending in the default canonical URL optional.
There's an example for a patch:
https://blog.taragana.com/how-to-modify-jekyll-seo-tag-plugin-to-remove-html-from-canonical-url-and-ogurl-15902