Martin Thoma
Martin Thoma

Reputation: 136207

How can I set the baseurl for Jekyll via command line?

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?

Upvotes: 7

Views: 2158

Answers (2)

thesecretmaster
thesecretmaster

Reputation: 1984

You can do this with the -b or --baseurl flag, as shown in the documentation here.

Upvotes: 3

imjared
imjared

Reputation: 20554

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.

Upvotes: 8

Related Questions