Jekyll deploy preview url; how to configure?

I am a novice at both jekyll and netlify, but I have successfully built and deployed https://sonomamatsuri.com.

Now I want to use deploy-previews, but I am having trouble configuring the url. It is available as an environment variable, but Jekyll doesn’t have a technique for accepting the url from the cli.

It wants the url to be in a _config.yml file. One can have jekyll read multiple config files, and later files override earlier ones. So for example I do local development like this:

bundle exec jekyll server --watch --config _config.yml,_config_dev.yml

So I need to get env var $DEPLOY_PRIME_URL into a config file. Can I write a build command like the following? Is there a filesystem available to me in the building context?

cat <<< "$DEPLOY_PRIME_URL" > "$_config_dev.yml"
printf "site: %s" "$DEPLOY_PRIME_URL" > _config_netlify.yml
jekyll build --config _config.yml,_config_netlify.yml

answering my own question, the following works:

printf "site: %s" "$DEPLOY_URL" > _config_netlify.yml; jekyll build --config _config.yml,_config_netlify.yml

thank you for sharing your solution!