gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.06k stars 7.48k forks source link

Create .htaccess file #1249

Closed bramp closed 7 years ago

bramp commented 9 years ago

It would be nice if hugo could optionally generate a .htaccess file. This would contain

ErrorDocument 404 404.html

as well as other content, such as forcing SSL, or perhaps when using the Aliases, it could do the re-direct (instead of meta-refresh).

ghost commented 9 years ago

This should only happen if the content does not already supply a .htaccess file.

maxmilton commented 8 years ago

Is this not something you should create yourself manually and put in the /static directory? Hugo is fairly agnostic when it comes to how your site is set up so I feel a custom .htacess file is more appropriate.

Plus not everyone uses Apache. For example I use Nginx so a .htaccess would be of no benefit.

Instead, why don't you create an example .htaccess config and put it in the hugo docs?

fedelibre commented 7 years ago

@MaxMilton Putting .htaccess in static/ might not be obvious for new users. I would slightly reword the 404 doc page to something like:

Apache - one way is to specify ErrorDocument 404 /404.html in an .htaccess file in your static/ directory.

bep commented 7 years ago

I'm pretty sure this should now be supported by creating a custom output format.

tutume commented 7 years ago

I unstertand that hugo is meant to be server agnostic and it is why it doesn't generate .htaccess. But how about allow generate any kind of file using the same template system? then we could generate not only .htaccess but a php file or any other kind of file that could be needed. I my case I'm trying to use it to generate different robots.txt (which works), a .htaccess and a contact.php file that must be different for local, staging and production. I can do it using other resources, but I think it could be much better in hugo. as I can rsync without any trouble.

rdwatters commented 7 years ago

@tutume This issue was closed because the functionality that you are asking for has been more or less added to the latest version(s) of Hugo. Please check the documentation for custom outputs and use the Discussion forum for support-related questions. Thanks for supporting Hugo! :smile:

https://discuss.gohugo.io

tutume commented 7 years ago

Wow, sorry, didn't realized that was released a new version. thanks!

maxmilton commented 7 years ago

Do custom outputs allow you to use any arbitrary file names or do they need to follow some set pattern? I saw some notes on allowing custom file endings but that looks like it enforces a dot in the name name.ext and so wouldn't allow for just name.

(Forgive me if this is a better question for https://discuss.gohugo.io/ but it seemed relevant this to thread!)

rdwatters commented 7 years ago

@MaxMilton Definitely a better conversation for the forums, please :smile:

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.