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

Revert #7253: "Don't reset site.url to localhost:4000 by default" #8620

Merged
merged 8 commits into from
Sep 15, 2021
4 changes: 2 additions & 2 deletions docs/_docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Here are some of the most common commands:

* `jekyll new PATH` - Creates a new Jekyll site with default gem-based theme at specified path. The directories will be created as necessary.
* `jekyll new PATH --blank` - Creates a new blank Jekyll site scaffold at specified path.
* `jekyll build` or `jekyll b` - Performs a one off build your site to `./_site` (by default).
* `jekyll serve` or `jekyll s` - Builds your site any time a source file changes and serves it locally.
* `jekyll build` or `jekyll b` - Performs a one off build your site to `./_site`, using the production configuration (by default).
ashmaroli marked this conversation as resolved.
Show resolved Hide resolved
* `jekyll serve` or `jekyll s` - Builds your site any time a source file changes and serves it locally, using placeholders for the site URLs to enable it to be served locally (by default). Should not be used to generate a site copy that will be deployed to a live website.
* `jekyll clean` - Removes all generated files: destination folder, metadata file, Sass and Jekyll caches.
* `jekyll help` - Shows help, optionally for a given subcommand, e.g. `jekyll help build`.
* `jekyll new-theme` - Creates a new Jekyll theme scaffold.
Expand Down
3 changes: 0 additions & 3 deletions lib/jekyll/commands/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ def format_url(ssl_enabled, address, port, baseurl = nil)

def default_url(opts)
config = configuration_from_options(opts)
auth = config.values_at("host", "port").join(":")
return config["url"] if auth == "127.0.0.1:4000"

format_url(
config["ssl_cert"] && config["ssl_key"],
config["host"] == "127.0.0.1" ? "localhost" : config["host"],
Expand Down
6 changes: 6 additions & 0 deletions test/test_commands_serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ def serve(opts)
expect(Jekyll).to receive(:env).and_return("development")
expect(Jekyll::Commands::Serve).to receive(:start_up_webrick)
end
should "set the site url by default to `http://localhost:4000`" do
@merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/")

assert_equal 1, Jekyll.sites.count
assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"]
end

should "take `host`, `port` and `ssl` into consideration if set" do
@merc.execute(:serve,
Expand Down