Skip to content
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

open browser when run on mac #5595

Closed
pjebs opened this issue Jan 9, 2019 · 15 comments
Closed

open browser when run on mac #5595

pjebs opened this issue Jan 9, 2019 · 15 comments

Comments

@pjebs
Copy link

pjebs commented Jan 9, 2019

Here is an idea:
If the GOOS is windows or darwin, when you run hugo server, it should open up the browser page immediately: http://localhost:1313/ using package: github.com/pkg/browser.

It should not do so after a live reload obviously.

@pjebs
Copy link
Author

pjebs commented Jan 9, 2019

@bep
Copy link
Member

bep commented Jan 10, 2019

No, I don't think that is a good idea, but I'll leave this issue open if others want to chime in.

@bep bep added the Proposal label Jan 10, 2019
@pjebs
Copy link
Author

pjebs commented Jan 10, 2019

the idea was to address something that always annoyed me (minor irritation). I only see positives and no negatives.

  • No-one runs an actual production server on windows or mac.
  • It doesn't break backward compatibility promises because the documentation never promised it.

What about a new flag that opens the browser up?

@RealOrangeOne
Copy link
Contributor

I quite like this idea, but it should be an opt-in feature, and not happen by default. Assuming it's smart enough to just open a new tab in an existing browser rather than forcefully spawning a new one.

Side note: Is there a reason this can't be done on the other supported platforms too?

@FelicianoTech
Copy link
Contributor

I agree with the orange colored one. If this was done at all, should be opt-in. I don't like the idea of a new tab opening automatically.

I would assume then a hugo serve flag.

@pjebs
Copy link
Author

pjebs commented Jan 10, 2019

Give me a flag name and I'll make a PR

@FelicianoTech
Copy link
Contributor

Well I use GitHub's hub CLI a lot and their command is hub browse to open a repository in the browser.

So I vote for a --browse flag.

hugo serve --browse would generate the site and open it up (localhost:1313 by default) in the browser.

@pjebs
Copy link
Author

pjebs commented Jan 11, 2019

browse is a bit ambiguous. It could mean browse files or browse website.
I think browser is better.

hugo server -D --browser

it's 1 extra letter plus a bit more self-explanatory in what it does.

@FelicianoTech
Copy link
Contributor

Sounds good to me.

@bep
Copy link
Member

bep commented Jan 11, 2019

Give me a flag name and I'll make a PR

As I said, I'm currently not merging such a feature. I'm not convinced that this is worth it; note that adding code to Hugo isn't just about ... adding it; I assume you need a dependency or two which adds work later in the build chain, and the code/tests needs to be maintained by someone.

@pjebs
Copy link
Author

pjebs commented Jan 11, 2019

No, I don't think that is a good idea, but I'll leave this issue open if others want to chime in.

@bep please close the issue. don't waste anyone's time keeping it open under the pretence that it is in theory possible to flip your opinion on the matter.

Having said that, thank you for your amazing product. It's the best static site generator out there in my honest opinion.

@DZuz14
Copy link

DZuz14 commented May 23, 2020

Gatsby and plenty of other generators do this. Its so simple that I have no idea why you wouldn't add it.

@pawelgrzybek
Copy link

Hi.

Thats probably not going to change your opinion @bep but personally I would find this feature useful too. I come from a JavaScript / Node.js space, and majority of the server tools implement this feature under the optional --open flag. Would be cool to see that as part of a hugo one day.

Thanks for building an amazing product!

@reorx
Copy link

reorx commented Jun 8, 2021

There are a lot of tools that run a HTTP server in command line, some can open the browser automatically, some just print the url in stdout, which can be easily opened by clicking in modern terminals. But hugo supports neither, which I think is the real problem here.

Currently hugo just prints:

Web Server is available at //localhost:1313/ (bind address 127.0.0.1)

..that is not a valid url to click.

Whether to open browser is a strategy division, but helping user to easily access the site server is a must-have feature for a CLI tool.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants