Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll not serving site locally

Tags:

macos

ruby

jekyll

Configuration: OSX 10.9.1, ruby 2.1.1 via RVM

I have created a new Jekyll site via the command jekyll new sitename.

I then enter that directory and issue the command jekyll serve.

I get the following notice:

Configuration file: /Users/George/sitename/_config.yml
            Source: /Users/George/sitename
       Destination: /Users/George/sitename/_site
      Generating... done.
    Server address: http://0.0.0.0:4000
  Server running... press ctrl-c to stop.

However when attempting to visit http://localhost:4000/ or http://0.0.0.0:4000/ my browser endlessly attempts to load the page.

I have checked and the site was built correctly including an index.html in /Users/George/sitename/_site/.

The _config.yml looks like so:

name: sitename
markdown: maruku
pygments: true

Does anyone know why Jekyll could be failing to serve the site but not throwing any errors?

Edit: If I change the port to 6000 and attempt to serve it then my browser instantly gives a page not found so there must be something interfering with port 4000 however the issue still stands.

like image 306
George Reith Avatar asked Oct 01 '22 07:10

George Reith


1 Answers

It's likely that something else is using port 4000 on your computer. You can find out by running the following command:

sudo lsof -i :4000

As you can run the server on another port, we'll move on to the next issue, setting the baseurl. In your _config.yml you can specify which baseurl to use, this will be the url from which all pages are served, so if you had baseurl: http://myawesomesite.com, Jekyll will expect them to be accessed from that url.

As you're working locally, you have two options:

Set the baseurl to / in your _config.yml:

baseurl: /

Launch Jekyll with the --baseurl flag:

$ jekyll serve -w --baseurl '/'

Additionally, you could specify the port as a flag:

$ jekyll server -w --baseurl '/' --port 4000

If you want further information about what's going on when you run jekyll, you can run the command with the --trace flag:

$ jekyll server -w --trace
like image 175
omgmog Avatar answered Oct 27 '22 16:10

omgmog