Closed StudioSpindle closed 5 years ago
Your --baseurl
shouldn't be an absolute URI to a domain.
baseurl
should just be a sub-location under the domain. For example, in https://www.some-url.com/blog/hello-world.html
, /blog
is your baseurl
On a separate note, jekyll build
does not respect JEKYLL_ENV
values..
@ashmaroli Thank you for the tip regarding the base URL. Based on your information I found this helpful page regarding URL structure in JEKYLL: https://byparker.com/blog/2014/clearing-up-confusion-around-baseurl/
Regarding the JEKYLL_ENV, how do you mean that exactly? Am I misinterpreting: https://jekyllrb.com/docs/configuration/environments/
@StudioSpindle Yes, Parker's blogpost is the best explanation out there. I should've linked to it myself.
The situation around JEKYLL_ENV
is a bit hazy at the moment.
The value of the environment variable is correctly utilized when Liquid templates are rendered but won't produce any change in your plain URLs.
At the same time when you use JEKYLL_ENV
with jekyll serve
, you'll find different results for
JEKYLL_ENV=development jekyll serve
and JEKYLL_ENV=production jekyll serve
.
cmd | result |
---|---|
JEKYLL_ENV=development bundle exec jekyll serve |
<link rel="canonical" href="http://localhost:4000/some-page"> |
bundle exec jekyll serve |
<link rel="canonical" href="http://localhost:4000/some-page"> |
JEKYLL_ENV=production bundle exec jekyll serve |
<link rel="canonical" href="https://www.some-url.com/some-page"> |
Thanks. That table is very clear. It seems that in the case of JEKYLL_ENV=develop (row 1) and without JEKYLL_ENV (row 2) being set, they both are producing development settings. That works. It picks up the url setting in the config file nicely. Also in the canonical link.
A colleague experienced some problems with the JEKYLL_ENV in bash using Windows. It did not set the env when it was put in front of the bundle exec command. We solved it by setting it as a config option in the config file.
For anyone running into the same problem: I'm using the one without JEKYLL_ENV being set on localhost, and with JEKYLL_ENV=development in Travis-CI. Based on the input before I've set an URL in the development config for the CI.
package.json
bundle exec jekyll build --config _config.yml, _config_development.yml
_config_development.yml
url: https://www.semi.technology # this is being picked up nicely in the canonical
environment: development
And of course a production config and the regular config file with all common settings.
I'm building the site with JEKYLL_ENV=develop bundle exec jekyll build --baseurl "https://www.some-url.com".
After the build, in the canonical the URL is:
<link rel="canonical" href="/https://www.some-url.com/some-page">
Anyone else experiencing or have experienced the same?