0

I am building a static site without the help of Jekyll or any other known static site builder. When deploying such site to a static site host like GitHub Pages or Netlify, these servers know to load software.html when I am accessing mydomain.com/software (without the .html extension).

Is there a way for me to reproduce this behavior when running a local, Ruby-based web server such as Puma? More specifically, I am using Ruby's adsf wrapper to launch a Puma server to serve my site locally for development.

My guess is that this should be possible by some rack middleware or rack configuration, I am just unable to identify the proper Google search for it.

I should probably mention that I am not interested in the directory/index.html approach, since all web servers I have seen add a trailing slash to the URL in these cases.

DannyB
  • 12,810
  • 5
  • 55
  • 65

1 Answers1

0

https://github.com/tommysundstrom/middleman-rack-optional-html might help.

actually the code is simple. add ".html" extention if the path doesn't end with "html".

https://github.com/tommysundstrom/middleman-rack-optional-html/blob/df1e50beca7599f3e47c5b83887573434f3253e3/lib/rack/middleman/optional_html.rb#L50

Pan Ke
  • 579
  • 2
  • 7
  • Thank you. This seems to do the trick. I am leaving the answer unaccepted for another day to see if someone else had any other suggestion, I will accept it if not. In the meantime, I also opened an [issue on adsf](https://github.com/ddfreyne/adsf/issues/16) suggesting to add this as a built in option. – DannyB Mar 26 '19 at 05:27