so I use Jekyll for walletscrutiny com and tried to upgrade Jekyll as I had issues with sorting. | reverse had no effect on the sorting.
I changed Gemfile line gem "jekyll", "~> 4.0.0" to gem "jekyll", "~> 4.2.0" and ran bundle update.
Before, running bundle exec jekyll serve --trace generated the page for localhost but now all the urls are using the production base_path. What happened between 4.0.1 and 4.2.0 and how do I fix this?
Can I suggest you convert most of your absolute URLs to relative URLs and see if that solves your problem? That should actually be good way to design Jekyll sites - I see a lot of people using absolute URLs unnecessarily. See my notes below.
I have a project running on 4.2, which has a custom URL in _config.yml. The change in Jekyll has not caused any breaks for me.
When I run jekyll serve I get:
Server address: http://127.0.0.1:4000
And relative URLs work as before e.g. {{ '/' | relative_url }} renders as / (excluding domain).
I think the change you are noticing is that any use of absolute URLs uses the configured URL and not localhost (even when JEKYLL_ENV=production is not set).
For example, if I do this:
{{ '/' | absolute_url}}
I get this:
https://example.com
I am guessing that this behavior is breaking your local dev experience, but only where you are using absolute URL. Some easy code changes can fix this. My recommendation is to use relative URLs throughout your site.
i.e. Do this
[Bar]({{ '/foo/bar.html' | relative_url }}
And actually it is more robust to use link as below, because it will give you a desirable error at build time if the link is broken instead of failing quietly.
[Bar]({% link foo/bar.md %}
And that will give you a relative URL by the way (no domain). It is also great to use for assets e.g. {% link assets/js/main.js %}.
And only use absolute URLs for things which need to be absolute. Like sitemap values, robots.txt values and metadata tags in your head tag. If you use plugins so handle those like the SEO and sitemap plugins, you won’t even have to use absolute_url anywhere in your own project code.
Thank you Michael. Your comments made me look into the right spot. I was using AcademicPages (don’t ask why. That’s how I found Jekyll) and there was an _includes/base_path:
So it turns out that most issues are fixed now but redirects still link to the production site. I grep site.url over my whole repo and don’t see any relevant site.url anymore. The rest is all not me.