Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jekyll

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?

like image 986
Martin Thoma Avatar asked Dec 10 '13 12:12

Martin Thoma


People also ask

How do I run Jekyll from the 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.

What are the URL and baseurl variables in Jekyll?

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.

What is a POST_URL link in Jekyll?

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.

What is the structure of Jekyll program?

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.


1 Answers

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.

like image 130
imjared Avatar answered Oct 17 '22 12:10

imjared