8000 Backport #8620 for v4.2.x · jekyll/jekyll@f73e8b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f73e8b1

Browse files
benlkashmaroli
authored andcommitted
Backport #8620 for v4.2.x
Revert #7253: "Don't reset site.url to localhost:4000 by default" This backports faef38b to 4.2-stable
1 parent ba024ea commit f73e8b1

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

docs/_docs/step-by-step/01-setup.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,16 @@ called `_site`.
7979
* `jekyll serve` - Does the same thing except it rebuilds any time you make
8080
a change and runs a local web server at `http://localhost:4000`.
8181

82-
When you're developing a site you'll use `jekyll serve` as it updates with any
83-
changes you make.
82+
{: .note .info}
83+
When you're developing a site, use `jekyll serve`. To force the browser to refresh with every change, use `jekyll serve --livereload`.
84+
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,
85+
as described in the [serve command options]({{ '/docs/configuration/options/#serve-command-options' | relative_url }}).
86+
87+
{: .note .warning}
88+
The version of the site that `jekyll serve` builds in `_site` is not suited for deployment. Links and asset URLs in sites created
89+
with `jekyll serve` will use `https://localhost:4000` or the value set with command-line configuration, instead of the values set
90+
in [your site's configuration file]({{ '/docs/configuration/' | relative_url }}). To learn about how to build your site when it's
91+
ready for deployment, read the [Deployment]({{ '/docs/step-by-step/10-deployment/' | relative_url }}) section of this tutorial.
8492

8593
Run `jekyll serve` and go to
8694
<a href="http://localhost:4000" target="_blank" data-proofer-ignore>http://localhost:4000</a> in

docs/_docs/step-by-step/10-deployment.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,21 @@ to do this is to run a production build:
143143
JEKYLL_ENV=production bundle exec jekyll build
144144
```
145145

146-
And copy the contents of `_site` to your server.
146+
And then copy the contents of `_site` to your server.
147+
148+
<div class="note warning">
149+
<h5>Destination folders are cleaned on site builds</h5>
150+
<p>
151+
The contents of <code>_site</code> are automatically cleaned, by default, when
152+
the site is built. Files or folders that are not created by your site's build
153+
process will be removed.
154+
</p>
155+
<p>
156+
Some files could be retained by specifying them within the <code>keep_files</code>
157+
configuration directive. Other files could be retained by keeping them in your
158+
assets directory.
159+
</p>
160+
</div>
147161

148162
A better way is to automate this process using a [CI](/docs/deployment/automated/)
149163
or [3rd party](/docs/deployment/third-party/).

lib/jekyll/commands/serve.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,6 @@ def format_url(ssl_enabled, address, port, baseurl = nil)
249249

250250
def default_url(opts)
251251
config = configuration_from_options(opts)
252-
auth = config.values_at("host", "port").join(":")
253-
return config["url"] if auth == "127.0.0.1:4000"
254-
255252
format_url(
256253
config["ssl_cert"] && config["ssl_key"],
257254
config["host"] == "127.0.0.1" ? "localhost" : config["host"],

test/test_commands_serve.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ def serve(opts)
232232
expect(Jekyll).to receive(:env).and_return("development")
233233
expect(Jekyll::Commands::Serve).to receive(:start_up_webrick)
234234
end
235+
should "set the site url by default to `http://localhost:4000`" do
236+
@merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/")
237+
238+
assert_equal 1, Jekyll.sites.count
239+
assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"]
240+
end
235241

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

0 commit comments

Comments
 (0)
0