When I want to test something local I use
baseurl: "http://localhost/blog/_site"
and when I deploy the website I use
baseurl: "http://martinthoma.github.io"
Changing _config.yml
every time is not a solution, because I would like to use a makefile like this:
Local testing:
make test
Deployment:
make deploy
So my question is: How can I set the baseurl for Jekyll via command line?
Command Line Usage. The Jekyll gem makes a jekyll executable available to you in your terminal. You can use this command in a number of ways: jekyll new - Creates a new Jekyll site with default gem-based theme. jekyll new --blank - Creates a new blank Jekyll site scaffold.
So what exactly are the url and baseurl variables? To start, both are site-wide variables set in the _config.yml file and affect how Jekyll builds URLs. I like to describe them like this: A site’s full URL including protocol, domain, and port (if applicable). Name of sub-directory the site is served from e.g., /blog.
The Jekyll post_url link will create a root-relative link when the site is parsed. Not only will it work anywhere, but Jekyll will also ensure that the post you link to actually exists when it parses the site. If the post doesn’t, it will throw a “Liquid Exception” telling you which file contained the bad link and which link was the problem.
The jekyll program has several commands but the structure is always: Typically you’ll use jekyll serve while developing locally and jekyll build when you need to generate the site for production.
I'd probably use a separate _config_prod.yml for production. When you build Jekyll, you can use the --config
flag and pass _config_prod.yml
to it as an option.
Check it out: https://jekyllrb.com/docs/configuration/#build-command-options
I imagine this would be easy enough to put into your makefile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With