Search code examples
htmlrubyjekyllgithub-pagesstatic-site

Jekyll posts aren't using layout accordingly


As described in "specifying layout for html posts in jekyll", Jekyll _posts should behave as any other page when it comes from its _layouts, however it isn't doing this way to me right now.

I'm developing this static site to be hosted in a Github Pages and everything else is working fine, but my posts are not.

I also checked the errors in "Jekyll post not generated" about Jekyll _posts, but the problem wasn't solved.

# _posts/2020-06-27-how-I-long-for-summer.md
---
layout: post
title:  How I long for Summer
cover: /assets/img/jhonny.jpg
date: 2020-06-27 20:56:28 -0300
categories: text
---
# _layouts/post.html
---
layout: default
---
# layouts/default.html
<!DOCTYPE html>
<html lang="en">

    {% include head.html %}

    <body>
        {% include navbar.html %}

        {{ content }}

        {%- include footer.html -%}
    </body>
</html>

So, even all regular pages are using default layout accordingly, my post pages have been rendered raw, as if I haven't declared any layout to them.

enter image description here

I'm using minima theme, but actually I was expecting it hasn't any effect since I overwrited post layout.

# _config.yml
markdown: kramdown
theme: minima
permalink: :year/:month/:day/:title

I tried what I could. Does anyone have a clue about what I'm doing wrong?


Solution

  • All of your CSS is using relative paths rather than absolute paths and therefore isn't being fetched correctly.

    In your various source code files (head.html, footer.html etc.).

    assets/js/main.min.js
    assets/js/theme.js
    assets/css/main.min.css
    assets/css/theme.css
    assets/main.css // not available
    

    Should be:

    /assets/js/main.min.js
    /assets/js/theme.js
    /assets/css/main.min.css
    /assets/css/theme.css
    /assets/main.css // not available
    

    Another solution is to use Liquid's relative_url filter:

    https://github.com/jekyll/minima/blob/master/_includes/head.html#L6

    https://jekyllrb.com/docs/liquid/filters/