Not Styling - On Localhost

I’m not getting styling on my local Jekyll staging server, run by “jekyll serve”. It seems to be a common problem to have styling problems on GitHub pages, but that works fine for me.

It depends on which way I reach the page. e.g. When I browse to / the page renders properly. That home page is currently displaying the content from _site/choosing-a-bank.html but when I browse to /choosing-a-bank the styling vanishes.

When I browse to / , and view the page source, it is a complete HTML document, but when I hit /choosing-a-bank I get only the content from the body – it is missing the head section and missing the body tag. It has only the content from the .md file converted to HTML.

What do I have configured wrong and how do I fix it?

Without knowing your site structure, I can’t be sure, but my guess is that you’ve added a relative path to your stylesheets. Something like /../style.css.

You can read about relative vs absolute urls here:

This thread might also be helpful: Relative URL and BaseURL

Wait … now that I read that again, it looks like you’re not passing your *.md files to a layout. If you are only getting the {{ content }} output in your built html file, check your front matter or your post defaults in your config file.

Thank you. It appears I’m not getting a layout assigned by default. Adding a layout to my front matter fixes it.

I use jekyll-admin to create my content and I think it used to add a layout to my front-matter by default and that’s stopped happening. I can’t say that for certain. All I can say for certain is that manually adding a layout to my front matter fixes it.

I’m several versions back, so I’m going to upgrade jekyll and the plugins to latest-and-greatest and see if that resumes getting layout added by default. (I do have it specified in _config.yml.)

OK. I’m on Jekyll 3.8.6. (I tried to go to 3.8.7 to match GitHub, but I’m using a docker container jekyll/jekyll and it doesn’t have a 3.8.7.) I’m using jekyll-admin 0.10.2. My _config.yml contains:

  - scope:
      path: ""
      type: "posts"
      layout: "post"
      description: ""
      author: ann_e_author

When I create a new page using jekyll-admin, and build my site, I’m not getting _layouts/post.html applied.

Any ideas on how to get the post.html layout applied to my posts without hand-adding it to the .md?

I’ve never used Docker so I’m not sure if that’s playing a role here …I doubt it, so I’m going to ignore that for now.

Do you have a post layout? Are you passing that file to a default layout?

You said your index.html file was working as expected. Is that file being passed to a layout or have you added all the HTML structure to that file directly?

Ouch. Found it. Somehow, long ago, most of my _config.yml lines acquired a leading space. Consequently, parts of my _config.yml were getting ignored. After correcting that, I’m correctly getting defaults applied.

Silently ignoring errors in _config.yml is… sub-optimal.