2
votes

I'm hosting a Jekyll site via Amazon S3. I keep the Jekyll instance running on a local machine so we can send posts to it and pipe things along automatically. This is working great.

The problem is in two instances (feed.xml and sitemap.xml) Jekyll is using 0.0.0.0:4000 in the html spit out to _site instead of the site.url set in _config.yml. If I don't set the --host=0.0.0.0 flag on jekyll serve then instead of that localhost:4000 is set as the url instead of site.url.

What can I do to keep the site running on our local network but still have the correct URL posted to the xml files?

3

3 Answers

2
votes

If you recently migrate to Jekyll 3.3.1 then your site.url will not work, because you're in development environment.

To test in production environment run JEKYLL_ENV=production bundle exec jekyll serve command.

I have also faced that problem in past, checkout my jekyll isssue.

For sitemap and XML feed you can aslo set another variable in your config file, like

fullurl: yourdomainname.com

And use site.fullurl instead of site.url in your XML sitemap/feed.

1
votes

You can define a _config_dev.yml where you can override config items.

On localhost, you will then run

jekyll serve --config _config.yml,_config_dev.yml

This is done like that on https://github.com/Phlow/feeling-responsive and the feed works fine on localhost

0
votes

remove url:~ key from _config.yml and use {{site.baseurl}} to add assets