I am new to jekyll, but I have built a site that is live, hosted on netlify.
Now I would like to use netlify deploy previews so I can test some changes without modifying the main public site. Such deploy previews are published at an url which I cannot predict. The url is available in an environment variable.
I can’t figure out how to get this url into my build. It needs to be in a _config.yml file, but I don’t know it in advance. I would like to override the site var in _config.yml on the jekyll build command line, but that doesn’t seem to be possible.
how much do you need the actual site url for? I think I only use it for the canonical url in the metadata, every where else I just have my urls start with a / and the relative link.
Sorry, not an answer to your question, I know.
Looking at your site it looks like most of the urls are relative, so when the site is at 1234.mysite.com vs https://mysite.com what is actually not working?
ah - yeah that url I think would break the relative-ness of the urls. [not sure about that now]
it looks like you are able to have a different build command for the preview site? if so I think you are on the right track, writing the preview url to the dev config file.
in your config files I think that if you DO NOT specify the url or baseurl it will probably work fine. If you do specify it the preview site may or may not break - I think it would be trying to pull the css from the prod site which may or may not work.
If you have any more trouble post a link to your repo if you can.
I’m totally thrilled with how easy and powerful this technology is. I moved that site from a very creaky old (expensively hosted) wordpress site in two days.
SSG FTW!
I used to use a CMS and static is so much easier to me.
Also, anyone reading this thread, not using the url or baseurl is not always good advice, probably best if you do use them unless there is a reason not to?