Is it possible to serve multiple Jekyll sites locally?

前端 未结 6 1515
旧时难觅i
旧时难觅i 2021-02-18 13:01

Every time I serve a Jekyll site from the command line it is served on port 4000. Two sites can\'t be served on the same port.

Is it possible to serve multiple Jekyll si

相关标签:
6条回答
  • 2021-02-18 13:14

    If you run it on mac docker client, provide host IP 0.0.0.0 will save your time a ton.

    jekyll serve --port 4001 --host 0.0.0.0
    

    By default, 127.0.0.1 is used for localhost and its NIC cannot receive any traffic from your mac host, whereas 0.0.0.0 means to accept traffic on all NICs

    0 讨论(0)
  • 2021-02-18 13:19

    You can also start the server with an additional argument --port 1234 or --host hostname. For example:

    $ jekyll serve --port 4001 --host my_hostname_or_ip
    

    You can view all the possible CLI flags from The official Jekyll documentation

    0 讨论(0)
  • 2021-02-18 13:27

    For multiple Jekyll sites, I just run this

    bundle exec jekyll serve --port <your_port_number>

    e.g

    bundle exec jekyll serve --port 4001

    0 讨论(0)
  • 2021-02-18 13:29

    Yes it is possible to serve multiple Jekyll sites locally by setting different port numbers for each site using the Local Server Port serve command option.

    See https://jekyllrb.com/docs/configuration/options/#serve-command-options.

    Set a port number other than Jekyll's default port (4000) in the site's _config.yml file or when serving the site via the command line.

    0 讨论(0)
  • 2021-02-18 13:29

    Open terminal, go to the Jekyll site directory and start the server

    jekyll serve --port 4001
    

    Go to another directory and start the second site

    jekyll serve --port 4002
    
    0 讨论(0)
  • 2021-02-18 13:36

    Two ways:

    1. In your _config.yml file, specify a port other than 4000 like this, for example:
      port: 4001
      
    2. OR (my preferred choice), add --port 4001 to your jekyll serve command, like this, for example:
      bundle exec jekyll serve --livereload --port 4001
      

    From: https://jekyllrb.com/docs/configuration/options/#serve-command-options

    0 讨论(0)
提交回复
热议问题