Generating URLs without .html extensions #156

Closed
pedrocr opened this Issue Apr 17, 2010 · 17 comments

Comments

Projects
None yet
10 participants

pedrocr commented Apr 17, 2010

I don't like having html extensions in urls. For a post named 2010-02-27-first-post.markdown I want to get:

URL: /2010/02/27/first-post
File: /2010/02/27/first-post.html

mod_rewrite or MultiViews takes care of serving that. By setting the permalink format to "pretty" or "/:categories/:year/:month/:day/:title" jekyll does:

URL: /2010/02/27/first-post
File: /2010/02/27/first-post/index.html

So I added a configuration option called no_post_dirs to get the first behavior. I did a branch (with test case) for it:

http://github.com/pedrocr/jekyll/tree/no_post_dirs

or more specifically the commit:

http://github.com/pedrocr/jekyll/commit/24b02d92766890956d7579d12ac488867d21d6c7

Cheers,

Pedro

agrif commented Aug 15, 2011

I would also like to be able to get rid of the html extension. I write my URLs to last, and if I want to switch a site to using Jekyll then I'd like to keep my old URLs (especially somewhere like GitHub where it's hard to set up redirects).

It's unreasonable to expect to be able to keep every URL intact, but extensionless article pages seems reasonable enough to me.

Since Jekyll isn't in charge of the Content-type header, this might be more oriented at GitHub Pages than Jekyll itself.

@agrif thanks for the link. I forget where I read about it being okay to allow .html at the end of URL, but I accepted it against my better judgement at the time. Today I'm convinced that .html is no different than having .php in your URLs. Thanks!

This change has been a huge help to me since I also write my URLs to last. Since this commit was created 2 years ago, the code to Jekyll has changed to the point where there were minor conflicts when I tried to merge it into the latest Jekyll code.

I resolved the merge conflicts and renamed the config value to avoid having a negative in a boolean config name.

I tagged the commit here, which was based off the most current master branch of Jekyll as of the time of writing this comment:

https://github.com/DanHerbert/jekyll/tree/post_dirs-config

ggarron commented Jul 6, 2012

@DanHerbert Sorry for the obvious question, but I've tried to use your fork and could not.
I have this in my _config

permalink: /:categories/:title
post_dirs: true

But I still have it generated something like

/linux/fedora-review/index.html

What am I doing wrong?

thanks a lof for your help.

ggarron commented Jul 6, 2012

@DanHerbert Sorry I have it now, it should be:

post_dirs: false

:)

@ggarron I apologize for the confusion. I unfortunately made the default value of the option opposite of most other Jekyll default boolean settings. I'm not entirely happy with the name still. While I still think avoiding negatives in variable names is important, in the future I'd like to come up with an option name that implies "false" is the default value and doesn't have a negative in the name. This is further proof that naming things is one of the only 2 hard things in computer science!

ggarron commented Jul 6, 2012

It is working great.

Are you going to issue a pull request?

On Jul 5, 2012, at 10:25 PM, DanHerbert
reply@reply.github.com
wrote:

@ggarron I apologize for the confusion. I unfortunately made the default value of the option opposite of most other Jekyll default boolean settings. I'm not entirely happy with the name still. While I still think avoiding negatives in variable names is important, in the future I'd like to come up with an option name that implies "false" is the default value and doesn't have a negative in the name. Just more proof than naming things is one of the only 2 hard things in computer science!


Reply to this email directly or view it on GitHub:
mojombo#156 (comment)

ggarron commented Jul 6, 2012

@DanHerbert are you thinking about asking a pull request to @mojombo ?

On Jul 5, 2012, at 10:26 PM, DanHerbert
reply@reply.github.com
wrote:

@ggarron I apologize for the confusion. I unfortunately made the default value of the option opposite of most other Jekyll default boolean settings. I'm not entirely happy with the name still. While I still think avoiding negatives in variable names is important, in the future I'd like to come up with an option name that implies "false" is the default value and doesn't have a negative in the name. This is further proof that naming things is one of the only 2 hard things in computer science!


Reply to this email directly or view it on GitHub:
mojombo#156 (comment)

@ggarron Not yet. I'd like to come up with a more user-friendly name and make sure any edge cases that could introduce more bugs are fixed before issuing a pull request.

For example, right now the patch checks the URL config for a .html extension. If the URL setting has no .html extension it will apply its behavior. But what if the URL has .htm or .rb as an extension, or something else that a user might decide to want. It's a rather unlikely scenario, but if a user decides to use an uncommon extension the generated files would have names like post-name.htm.html and links would be generated as post-name.htm which is obviously undesirable.

ggarron commented Jul 6, 2012

@DanHerbert Thanks
I'll use your fork for my production site with nginx and try_files

ungoldman referenced this issue in aipd-wdim332/aipd-wdim332.github.com Oct 15, 2012

Closed

get rid of html extension #1

Owner

parkr commented Dec 19, 2012

See #691, #219.

dotmike commented Mar 14, 2013

This issue actually turned out to be pretty simple to fix. Simply update your permalink to:

permalink: pretty

in your _config.yml

Owner

parkr commented Mar 17, 2013

@dotmike permalink: pretty just makes it an index.html file in a directory. That satisfies the need here, though.

parkr closed this Mar 17, 2013

saivann commented Mar 23, 2013

Except that it adds a trailing dash in the url ( / ), breaking relative urls between index.html and other html files in the same directory.

ile commented Oct 16, 2013

I would also like to have clean urls without the trailing slash.

Can this be done & re-opened? I.e. would it work on GitHub if the files were just without the .html extension (and without any extension) — would they be served as text/html if the files were e.g. /2013/10/16/hello-world?

saivann commented Oct 16, 2013

Keeping the .html extension allows to use clean urls without the trailing slash, and most web servers can serve files this way too. Current compromise is the best we can achieve (to my knowledge).

ile commented Oct 16, 2013

Yes, outside GitHub that would be fine. Well, I'm just expressing my hope here, it's not critical but definitely would be nice.

jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.