0
votes

So i'm making a blog in Jekyll based on a start bootstrap theme (also following a course on Udemy) I've made the post layout etc, and everything works fine until i add a second post that messes up everything.

Post layout with only one post (remove the /remove-this/second-image/ to get the first and second link to see the layout with one post, left link, and the layout with two posts, right link sry I didn't have sufficient reputation ^^)

I would like to know how to fix this problem Thanks for helping

here is the code used for the post layout (I also made a GitHub repository):

{% include post_header.html %}

<!-- Post Content -->
<article>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                {{ content }}
            </div>
        </div>
    </div>
</article>


{% include footer.html %}

includes:
post_header.html:

{% for post in site.posts %}
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title> {{ post.title }} </title>

    <!-- Bootstrap Core CSS -->
    <link href="{{ site.url }}/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="{{ site.url }}/css/clean-blog.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <!-- Navigation -->
    {% include nav.html %}

    <!-- Post Header -->
     <!-- Page Header -->
    <!-- Set your background image for this header on the line below. -->
    <header class="intro-header" style="background-image: url('{{ site.url }}/img/{{ post.coverImg }}')">
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                    <div class="post-heading">
                        <h1>{{ post.title }}</h1>
                        <h2 class="subheading">{{ post.description }}</h2>
                        <span class="meta">PubliƩ par <a href="#">{{ post.author }}</a> on {{ post.date | date_to_string }}</span>
                    </div>
                </div>
            </div>
        </div>
    </header>

    {% endfor %}

footer.html:

    <!-- Footer -->
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                    <ul class="list-inline text-center">
                        <li>
                            <a href="https://twitter.com/Bonny_AG" target="_blank">
                                <span class="fa-stack fa-lg">
                                    <i class="fa fa-circle fa-stack-2x"></i>
                                    <i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
                                </span>
                            </a>
                        </li>
                        <li>
                            <a href="#" target="_blank">
                                <span class="fa-stack fa-lg">
                                    <i class="fa fa-circle fa-stack-2x"></i>
                                    <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
                                </span>
                            </a>
                        </li>
                        <li>
                            <a href="https://github.com/BonnyAG" target="_blank">
                                <span class="fa-stack fa-lg">
                                    <i class="fa fa-circle fa-stack-2x"></i>
                                    <i class="fa fa-github fa-stack-1x fa-inverse"></i>
                                </span>
                            </a>
                        </li>
                    </ul>
                    <p class="copyright text-muted">Copyright &copy;BonnyAG 2015, All content made by BonnyAG for this blog, please ask permission before using the content in other websites.</p>
                </div>
            </div>
        </div>
    </footer>

    <!-- jQuery -->
    <script src="{{ site.url }}/js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="{{ site.url }}/js/bootstrap.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="{{ site.url }}/js/clean-blog.min.js"></script>

</body>

</html>
1

1 Answers

0
votes

So after digging in a little deeper i found that what caused the error was that i had a header for static pages and one for blog posts and that was causing the error. So here is the code fix

Post layout:

{% include header.html %}

<!-- Post Content -->
<article>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                {{ content }}
            </div>
        </div>
    </div>
</article>

{% include footer.html %}

header.html:

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>{{ page.title }}</title>

    <!-- Bootstrap Core CSS -->
    <link href="{{ site.url }}/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="{{ site.url }}/css/clean-blog.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

{% include nav.html %}

<body>

    <!-- Page Header -->
    <!-- Set your background image for this header on the line below. -->
    <header class="intro-header" style="background-image: url('{{ site.url }}/img/{{ page.coverImg }}')">
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                    {% if page.author %}
                            <div class="post-heading">
                                <h1>{{ page.title }}</h1>
                                <h2 class="subheading">{{ page.description }}</h2>
                                <span class="meta">PubliƩ par <a href="#">{{ page.author }}</a> on {{ page.date | date_to_string }}</span>
                            </div>
                    {% else %}
                        <div class="site-heading">
                            <h1>{{ page.header }}</h1>
                            <hr class="small">
                            <span class="subheading">{{ page.description }}</span>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </header>