mmistakes / jekyll-theme-hpstr

A Jekyll theme with some tumble-log tendencies.
https://mmistakes.github.io/jekyll-theme-hpstr/
MIT License
981 stars 1.44k forks source link

Jekyll server url overwrites site url with Jekyll 3.3.0 #167

Closed rhempel closed 7 years ago

rhempel commented 8 years ago

Had a hell of a time this morning when I opened a new project based on hpstr-jekyll-theme after doing a bundle-update - the server url was overwriting the site url which was definitely NOT happening with Jekyll 3.2.1

A bit of background - I have successfully developed an internal site using this theme as it stood on September 15 and serve the site from a Vagrant instance like so:

bundle exec jekyll serve --host=0.0.0.0 --port=4000   --force_poll

And I leave url: blank in my _config.yml file. When the user requests (for example) the index.html file the URLs should look like this:

<link rel="stylesheet" href="/assets/css/main.css">

And indeed this was the case for the existing site that was built with Jekyll 3.2.1 which was current when I built the site.

Fast forward to this morning and I branched my site to mess about with the theme colours (I wanted to invert the colour scheme to be dark instead of light) - the latest version of Jekyll is now 3.3.0 and the exact same _config.yml and Jekyll serve command line pushes out urls that look like this:

<link rel="stylesheet" href="http://0.0.0.0:4000/assets/css/main.css">

Yeah - that's not going to work at all :-)

So I'm downgrading to Jekyll 3.2.1 but anyone that clones hpstr is going to run into this with Jekyll 3.3.0 so heads up!

mmistakes commented 8 years ago

If you set JEKYLL_ENV=production it should get around this new behavior. jekyll serve now automatically sets site.url to http://localhost:4000 when in development, which is the default environment.

https://jekyllrb.com/docs/configuration/#specifying-a-jekyll-environment-at-build-time

If you want to avoid this in 3.3 you'll want to run Jekyll like this

JEKYLL_ENV=production bundle exec jekyll serve

rhempel commented 8 years ago

But it's not "production" - I'm running this on a vagrant machine precisely for the purpose of testing. I'll test to see if it fixes the problem though and move on.

mmistakes commented 8 years ago

I get that your Vagrant machine isn't technically a production env. Unfortunately setting the production flag with Jekyll is the only way to get around it auto assigning url in 3.3.0. At least as far as I know.

white-gecko commented 7 years ago

By the way this behavior is not documented in https://jekyllrb.com/docs/variables/

mmistakes commented 7 years ago

@white-gecko It's documented, just not in a place anyone is likely to look for it. http://jekyllrb.com/news/#3-siteurl-is-set-by-the-development-server