gohugoio / hugo

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

Command line flag to open localhost:1313 #13040

Closed rjc123 closed 1 week ago

rjc123 commented 1 week ago

As a not-very-technical hugo user I would like to generate my site locally to test (heavily using hugo server -D) and see it immediately upon build in a local browser. So that I can review it works as I would have expected.

hugo server -D && open http://localhost:1313 doesn't function, as it requires the server command to complete before opening the browser open http://localhost:1313 && hugo server -D does function as needed, but doesn't match the order one would think about these things.

The best result would be hugo server -D -o -- so that the browser opens to the localhost immediately on the first build of the site, leaving the server running.

bep commented 1 week ago

I think we have had this discussion before, and I think the argument against it was that it wasn't a good/simple multi platform way to do this. But I see now that this exists, which looks solid enough:

https://github.com/pkg/browser

As to flags, I would suggest we go for -O (uppercase). I have tried to make it lowercase=configuration, uppercase=actions. Some of the uppercase are a little bit borderline, but I think it makes sense.

So:

hugo server -O