Problem hosting under Internet Information Service ( IIS ) locally

Hi,

I am Be Hai, from Melbourne, Victioria, Australia. I have only learned Jekyll in the past 3 days, but I have been a software writer in the past 20 years or so. I am very familiar with HTML, CSS etc.

The environment I am using is “Windows Subsystem for Linux” ( WSL2 ), running Ubuntu 20.4.

I went through all tutorials on Jekyll – I am very happy with what I have learned.

And I have successfully put my Jekyll generate “site” onto GitHub IO:

Also on my local machine, in WSL2 works as per instructions. That is:

when I run

bundle exec jekyll serve

Then on a Windows browser, I run:

"localhost colon( : ) 4000"

I got the same as github’s

I have this project locally in “D:\Codes\behai-nguyen_github_io”, The generated site is in “D:\Codes\behai-nguyen_github_io\_site”.

THE PROBLEM:

In my understanding / thinking / assumption, if I set a virtual
directory, “behai”, in Internet Information Service ( IIS ) pointings
to “D:\Codes\behai-nguyen_github_io_site”, then when I run:

http://localhost/behai/

it shoud work – but I have broken pages, no CSS applied.

WHAT I HAVE TRIED and STILL DOES NOT WORK:

A look into “D:\Codes\behai-nguyen_github_io\_site” shows that it does not seem to include theme files.

So I copied the following folder from WSL2 to D:\Codes\behai-nguyen_github_io\

/home/behai/gems/gems/minima-2.5.1/_includes
/home/behai/gems/gems/minima-2.5.1/_layouts
/home/behai/gems/gems/minima-2.5.1/_sass
/home/behai/gems/gems/minima-2.5.1/assets

Then, I ran:

bundle exec jekyll serve – “http localhost behai” still does not work. “localhost colon( : ) 4000” works.

jekyll build – “http localhost behai” still does not work.

After these two commands, content of “_site” still did not change.

This problem also means: if I upload the entire “D:\Codes\behai-nguyen_github_io\_site” to a hosting site, my site will not work.

Would you please kindly help me with this issue? I know it is possible, I just don’t know how to do it yet.

Thank you and best regards,

Be Hai Nguyen.

I found out what it is. To recap, I want to run the generated site as:

http colon ( : ) // localhost / behai /

In project config file, _config.yml, I changed baseurl and url:

baseurl: "/behai" # the subpath of your site, e.g. /blog
url: "http://localhost" # the base hostname & protocol for your site, e.g. http colon ( : ) // example.com

Generated HTMLs now have the appropriate path for CSS:

<link rel="stylesheet" href="/behai/assets/main.css">

I am guessing then, I will have to set these two values appropriately for the domain the site will be hosted on.

I hope this would help someone.

Be Hai Nguyen.

You are correct that you want to change the baseurl and url to what you expect for production. However, do not stress changing your url every time you run locally.

For example, check out these settings in _config.yml:

baseurl: "/my-website" # the subpath of your site, e.g. /blog
url: "https://mywebsite.com" # the base hostname & protocol for your site, e.g. http://example.com

When you use jekyll build, those settings get used.

However, when you are testing your site with jekyll serve (or more commonly bundle exec jekyll serve --livereload), you will notice that Jekyll figures out the correct settings and provide you with a URL that looks like this:

http://127.0.0.1:4000/my-website/

The point I am making here is to configure your baseurl and url with what you expect them to be for production. When you test locally, jekyll serve will automatically adjust the url for you.

1 Like