I've created a new site at GitHub Pages, using Jekyll. I'm using a custom permalink format in the following form:
permalink: /:title
This is because I've moved my blog over from WordPress and want previously existing links to continue working. When I run the server locally with "jekyll serve", it works fine - however, once it's hosted on GitHub Pages, the links don't get parsed correctly, leading to tags like this one:
<a class="post-link" href="/:title">Markdown and HTML</a>
Further information - I am using a custom domain, with my _config.yml containing:
url: http://domain.com
And my CNAME containing:
domain.com
Could anyone shed some light on why this occurs? Thanks.
You're trying to use a functionality that was implemented in Jekyll 2.5.
As Github pages runs Jekyll 2.4, it breaks :-(
The only way to do what you want is to set default permalink in you _config.yml file.
permalink: :title/
Related
I have a page with the slug about-us. By default, Jekyll builds this:
/about-us
/index.html
However, I want this instead:
/about-us.html
Reading through the Permalinks documentation, it looked like I could use this in the config
permalink: /:slug:output_ext
However, this produces the same output as above.
How I configure Jekyll to write the pages as their own .html page, rather than in a folder with an index.html?
Jekyll only generates /about-us/index.html if you've permalink: /about-us/ in the page's front matter or if you've permalink: pretty in your config file.
Ensuring neither of the above conditions should generate /about-us.html
I have a jekyll blog with some static files, my blog index is generating at /blog while all the posts are getting generated at /. How can I make it so that the posts get generated inside the /blog subdirectory?
Note that I am not looking to move the whole Jekyll installation to a subdirectory as I still want my sitemap, static pages etc to be at root.
I am not sure what code to provide but I am using this theme with gulp 4 and other upgraded packages.
Change permalink in _config.yml from
permalink: /:title/
to
permalink: /blog/:title/
You can read more about permalinks in Jekyll documentation.
I'm new to using jekyll and I think I'm missing something but I can't figure out what.
I built a jekyll page which I compile using
bundle exec jekyll build
then I uploaded the contents of the _site folder to the public_html/ folder of my webhoster (name.com).
All menu links, lead to 404 error pages: The menu links generated in the html files point to things like "https://myurl.com/people" while the actual file is called "people.html" so that is why I'm getting a 404. The way I see it, I either need jekyll to generate menu links that include the ".html" file extension, or somehow get my webhoster to serve "people.html" when "people" is requested.
Chris
To alter the link structure for all of your files, use permalink (with proper formatting) in your config file. For example:
# _config.yml
# same as `permalink: none`
# note that its ':output_ext' instead of '.html'
permalink: /:categories/:title:output_ext
Source: Official Docs
From the Jekyll docs it says (using .md format):
Clean URLs can also be achieved using the permalink front matter variable. In the example above, using the first method, you can get URL http://example.com/other for the file other.md by setting this at the top of the file: permalink: /other
Here is an example my page front matter:
---
layout: page
title: Contact
permalink: /contact
---
Everything works fine when I'm using jekyll serve but when I build and upload to my static host it doesn't work. The file structure Jekyll outputs doesn't make sense for the functionality it claims from the docs.
.
|-- css/
|-- index.html # => http://example.com/
└── contact.md # => http://example.com/contact.html
I want to be able to go to http://example.com/contact and have it show contact.md. I know I could have similar functionality by manually putting my files in folders (and then renaming them all to index.html) like it says in the docs here, but I don't want to have to go through the extra step and I don't prefer the trailing / e.g. http://example.com/other/.
I am using Jekyll 3.0.1
I have found these questions but they don't address the problem I'm facing.
How to link to a page with page.url without the html extension in Jekyll?
How to make all posts have a permalink with custom format "domain.com/blog/title"?
Can Jekyll omit index.html from folder URLs?
I am also using clean permalink in my jekyll blog.
Here is my frontmatter:
---
layout: directory
title: About
permalink: about/
---
Got any different? , it is trailing slash at the end of URL. I know, you don't want to see any trailing slash at the end of URL, but for that you need to use nginx, because Jekyll generate all post/page like this /folder/index.html.
I think you are doing it correctly, it is just a matter of configuring your webserver properly (assuming it supports removing the extension). It works properly locally cause the built in jekyll webserver can do it by default. The docs have info on this here:
http://jekyllrb.com/docs/permalinks/#extensionless-permalinks
On AWS S3 it says you can host with extensionless urls by uploading files with no extension at all, and then setting the content type to text/html. I don't think it is possible to get jekyll to output contact.html as just contact with no extension. So you get the web server to remove the extension, if it supports that (on s3 I use the trailing /).
This has some interesting info too:
https://github.com/jekyll/jekyll/issues/3345
I am developing my blog in Jekyll (3.0.0 beta), currently on localhost,
When i am trying to implement the pretty permalink and i try to visit a post it shows a WEBrick error.
If i apply the /:year/:month/:day/:title.html it works fine do you have a clue why isn't it working with pretty permalinks?
This is the error I get:
/2015/08/03/are-permas-working.html' not found. WEBrick/1.3.1 (Ruby/2.1.6/2015-04-13) at localhost:4000
Once you set Jekyll permalinks to pretty in _config.yml like so:
permalink : pretty
... and restart your WEBrick server (a restart of the server instance using jekyll serve or bundle exec jekyll serve [if following GitHub] is needed for the new values to take effect, your permalinks will no longer be in the format of YYYY/MM/DD/title-slug.html since they are now "pretty". The new format for your links will be /:categories/:year/:month/:day/:title/. This is in accordance to the format determined by the pretty variable as defined here in the documentation.
What this means for you is that your original link for the 'Are permas working' post is no longer at localhost:4000/2015/08/03/are-permas-working.html, rather they are now at localhost:4000/2015/08/03/are-permas-working/ since you don't have a category defined.
You're experiencing this error because after you've made the change and restarted your server you most likely did not navigate to the post from your homepage (which will have that new link to point to the post), rather you just refreshed the page on your browser, which will throw a 404 since the page is no longer there.
Bonus, Jekyll makes posts pretty by creating folders 2015 -> 08 -> 03, and then a folder for that specific post, with an index.html inside it.
Also, if you wanted "pretty-fied" links that don't have the dates there, you'll need to manually specify that using this:
permalink: "/:categories/:title"
This ensure will hide the .html extension and also get rid of date values.
EDIT: From the comments I stated that using /:title for permalinks might not work since there are conflicts with non-post pages, I stand corrected. If you wanted short permalinks like user.github.io/title-of-blog-post/ you would just need to set permalink : /:title and you're good to go. However, if you have non-post pages such as an about page, a credits page, you should explicitly set permalinks on those pages to be /about and /credits on the YAML frontmatter to avoid the edge case of also having a blog post with the title about and accidentally overwriting the non-post page.