Donut
Donut

Reputation: 47

Something that I do not understand with jekyll permalink

I'm working on my personal blog. All was fine while using jekyll serve locally but when I wanted to copy it to my website, all the post links raised a 404 error.

After investigating, it appeared that the links missed the trailing ".html". That is not a problem for Jekyll serve but it does not work remotely.

Here is my initial _config.yml, which works fine with jekyll serve

title: DonutBlog
author: DonutMan
#email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
  Des équations, des livres et du Shell
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://blog.les-vigneron.fr" # the base hostname & protocol for your site, e.g. http://example.com
#twitter_username: jekyllrb
#github_username:  jekyll

# Build settings
theme: minima
#plugins:
#  - jekyll-feed

permalink: /:categories/:title

# added a page by category, following https://www.valhalla.fr/2017/10/16/jekyll-une-page-par-categorie/

collections:
  category:
    output: true # générer la page HTML
    permalink: /:collection/:name/index.html
    # exemple -> /category/informatique/index.html

The main page works fine with both local and external access but here's an example of link that works fine locally but raise a 404 eror while used externally :

http://blog.les-vigneron.fr/litterature/tous-les-mots-sont-freres

So to correct this, I added a ".html" at the end of the permalink in _config.yml

permalink: /:categories/:title.html

Now all the post links look like this one :

http://blog.les-vigneron.fr/litterature/tous-les-mots-sont-freres.html

This is compatible with both local (jekyll serve) and external but I know it is a really bad hack.

Do you know what I'm missing here?

Upvotes: 1

Views: 245

Answers (1)

sayzlim
sayzlim

Reputation: 275

You're generating a file instead of a folder. Try adding / to the end of the permalink:

permalink: /:categories/:title/

Doing so will generate a folder for each title and put an index.html file inside them.

Upvotes: 0

Related Questions