pages-gem icon indicating copy to clipboard operation
pages-gem copied to clipboard

baseurl of '/' now breaks on GitHub pages

Open dracos opened this issue 6 years ago • 6 comments

Before submitting an issue, please be sure to

This issue affects

  • [x] The site generated by GitHub Pages
  • [ ] Building sites locally

What did you do (e.g., steps to reproduce)

I pushed my site with a small change from the last push couple of weeks ago.

What did you expect to happen?

The site to appear as it has done for years :)

What happened instead?

All the styling is lost, because the upgrade to jekyll-github-metadata v2.5.0 means that a config with baseurl set to / is now overridden to baseurl "" and the templates were relying on baseurl being set to /. I understand that baseurl: "/" is incorrect and shouldn't be used (though I can't find any official documentation saying why this shouldn't work okay, only links to Parker's 2014 blog post), but anyway, I didn't expect the whole site to break by adding a new blog post :)

Additional information

  • Link to the live site (if applicable): http://fixmystreet.org/overview/ (now fixed by https://github.com/mysociety/fixmystreet/commit/f3bb932c1b7f09fd4bffef2ef403c11008f9fcb0)
  • Link to the source repo (if applicable): https://github.com/mysociety/fixmystreet/tree/a1dfd4acb844162227c27d4e19c6e863cc96a692

dracos avatar Jul 18 '17 21:07 dracos

I just made 2 line of changes and css of my entire site broke. There should definitely be a shout out when such breaking changes are introduced. Anyway what is the solution for this? Changing {{ site.baseurl }} to {{ "/" | relative_url }} will work?

ankitbko avatar Aug 16 '17 13:08 ankitbko

That is what I did in the commit I linked to above, yes (or if you have e.g. {{ site.baseurl }}sub/page/ changing that to {{ "/sub/page/" | relative_url }} and so on).

dracos avatar Aug 16 '17 13:08 dracos

@dracos Thanks. By the way, it seems to be working fine locally. Any idea how to replicate it locally?

ankitbko avatar Aug 16 '17 15:08 ankitbko

@ankitbko You need JEKYLL_ENV=production so that should_add_fallbacks passes, and you need to add jekyll-github-metadata to your gems in _config.yml. With those two things, I get the same issue replicated locally.

dracos avatar Aug 16 '17 16:08 dracos

@dracos thanks for the tip 💪 . I was able to reproduce the issue locally.

vgaidarji avatar Dec 21 '17 08:12 vgaidarji

YAY! thanks for sharing the workaround!

meleu avatar Mar 15 '18 19:03 meleu