Skip to content

Commit

Permalink
Backport benlk-revert-pr-7253 from jekyll#8620 to 4.2-stable [merge c…
Browse files Browse the repository at this point in the history
…onflicts]
  • Loading branch information
benlk authored and ashmaroli committed Sep 15, 2021
1 parent ba024ea commit a995c3c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
14 changes: 14 additions & 0 deletions docs/_docs/step-by-step/01-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,22 @@ called `_site`.
* `jekyll serve` - Does the same thing except it rebuilds any time you make
a change and runs a local web server at `http://localhost:4000`.

<<<<<<< HEAD
When you're developing a site you'll use `jekyll serve` as it updates with any
changes you make.
=======
{: .note .info}
When you're developing a site, use `jekyll serve`. To force the browser to refresh with every change, use `jekyll serve --livereload`.
If there's a conflict or you'd like Jekyll to serve your development site at a different URL, use the `--host` and `--port` arguments,
as described in the [serve command options]({{ '/docs/configuration/options/#serve-command-options' | relative_url }}).

{: .note .warning}
The version of the site that `jekyll serve` builds in `_site` is not suited for deployment. Links and asset URLs in sites created
with `jekyll serve` will use `https://localhost:4000` or the value set with command-line configuration, instead of the values set
in [your site's configuration file]({{ '/docs/configuration/' | relative_url }}). To learn about how to build your site when it's
ready for deployment, read the [Deployment]({{ '/docs/step-by-step/10-deployment/' | relative_url }}) section of this tutorial.

>>>>>>> faef38b5d... Revert #7253: "Don't reset site.url to localhost:4000 by default" (#8620)
Run `jekyll serve` and go to
<a href="http://localhost:4000" target="_blank" data-proofer-ignore>http://localhost:4000</a> in
Expand Down
16 changes: 15 additions & 1 deletion docs/_docs/step-by-step/10-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,21 @@ to do this is to run a production build:
JEKYLL_ENV=production bundle exec jekyll build
```

And copy the contents of `_site` to your server.
And then copy the contents of `_site` to your server.

<div class="note warning">
<h5>Destination folders are cleaned on site builds</h5>
<p>
The contents of <code>_site</code> are automatically cleaned, by default, when
the site is built. Files or folders that are not created by your site's build
process will be removed.
</p>
<p>
Some files could be retained by specifying them within the <code>keep_files</code>
configuration directive. Other files could be retained by keeping them in your
assets directory.
</p>
</div>

A better way is to automate this process using a [CI](/docs/deployment/automated/)
or [3rd party](/docs/deployment/third-party/).
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

0 comments on commit a995c3c

Please sign in to comment.