New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`hugo server` should check for /foo.html when requesting /foo #2242

Closed
octref opened this Issue Jun 29, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@octref
Contributor

octref commented Jun 29, 2016

I'm using https://surge.sh/ to deploy my hugo site. It has a great clean url feature, so if you have /foo.html, /foo will get it, /foo/ will redirect to /foo.

So now I'm creating content/foo.md, and enabling uglyurls so hugo generates /foo.html.

In some pages, such as listing page, I'm now using {{ trim .RelPermalink ".html" }} to use clean url in href. However, this causes problem with hugo server. A request of /foo doesn't check the existence of /foo.html, but directs to /foo/ to try /foo/index.html immediately.

@anthonyfok anthonyfok added the Wish label Jul 1, 2016

@octref

This comment has been minimized.

Contributor

octref commented Oct 2, 2016

@anthonyfok Hey I'm interested in doing this myself, but I don't have much experience with golang. or hugo. Would you mind giving me a pointer as to where to start?

@bep

This comment has been minimized.

Member

bep commented Oct 2, 2016

@octref this issue is in the category of "we should most likely not do this", and if so only if it is really simple and someone is providing a finished solution for it. Teaching you Golang doesn't fit that bill.

@octref

This comment has been minimized.

Contributor

octref commented Oct 2, 2016

@bep I understand that. Just want to know where to start. Guess I'll look into https://github.com/spf13/hugo/blob/master/commands/server.go and how net/http fileserver handles request.

Just wondering, is it that you are against this feature?
If not, are you OK if I do it this way?

/foo serves /foo.html if it's available. If not, directs to /foo/ and behave like it is before.

@octref

This comment has been minimized.

Contributor

octref commented Oct 2, 2016

Knowing "we should most likely not do this" is useful as I can possibly avoid the awkward situation where I take time to do a PR and you don't want this feature at all.

Also saw your comment at #874:

@rustyoz I agree, but I still feels that the FileServer devs should have made this extensible in the first place. When they sober up from GopherCon I will post an issue; but that will be Go 1.6 at best.

I guess this discussion can hold until we decide what to do about a REST api.

So as for approach to this problem:

  • Is FileServer made extensible now go is 1.7?
  • Does hugo need to take dep on https://github.com/julienschmidt/httprouter to implement this feature?
  • Or is it you are doing the REST api(didn't see it in code, and didn't find it on roadmap)?
@octref

This comment has been minimized.

Contributor

octref commented Oct 24, 2016

Guess I'll should switch back to jekyll.

@octref octref closed this Oct 24, 2016

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