karrot42
karrot42

Reputation: 13

I can serve a brand new Jekyll site, but I can't build it

Basically, when I make a brand new jekyll site I can go in to the directory and do bundle exec jekyll serve and see the proper site at 127.0.0.1:4000, but when I do bundle exec jekyll build I get a broken index.html that when opened looks like this

enter image description here

The other odd thing is that if I change the url: and baser: in my _config.yml to a website I've previously made and hosted, then it works fine.

I think I've messed something up with my ruby install (macOS Mojave), or previously figured out a way around this problem that I no longer remember so those previous sites url and baseurl work fine.

Upvotes: 0

Views: 403

Answers (1)

ashmaroli
ashmaroli

Reputation: 5444

You may be pleased to know that there's nothing wrong with your Ruby installation or the Jekyll version itself if bundle exec jekyll serve returns results as expected.

The sites generated by Jekyll are meant to be used with a server. That's the very reason the jekyll serve command exists. jekyll serve first builds your site and then serves it on the browser via the WEBrick webserver.

Running bundle exec jekyll build will give you a production-ready site (in the _site directory by default). But it has to be hosted somewhere like GitHub Pages or Netlify or CloudCannon before you can navigate through the site.

For local browsing, bundle exec jekyll serve is the way.

Upvotes: 2

Related Questions