PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label jekyll. Show all posts
Showing posts with label jekyll. Show all posts

Monday, July 18, 2022

[FIXED] Why does liquid {%SEO%} tag not get integrated into head? instead it shows in body

 July 18, 2022     document-body, head, jekyll, liquid     No comments   

Issue

For some unknown reason any LIQUID syntax used inside <head> ends up in the <body>

What I have done?

1) I cloned a template and build my own layout with JEKYLL static site generator.
2) I installed all gems (check gemlist: 'jekyll-seo-tag' 'liquid 4.0')
3) I configured config.yml
4) I added {%SEO%} to <head>

Minimal

<head>

  <meta charset="utf-8">
  <meta name="author" content="Gino Ludikhuyze">
  <meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- Title -->

  <title>title</title>

  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="css/responsive.css">
  <script src="js/vendor/modernizr-2.8.3.min.js"></script>

  {% seo %}

</head>

What is happening?

If I render the website, online or local host, It shows a white GAP at the top. If I inspect it. It shows my liquid TAG in the body.

What I expect to happen?

That liquid should work in cohesion with jekyll.

Link to repo: https://github.com/bomengeduld/reno
Link to website: https://bomengeduld.github.io/reno/


Solution

Your index.html should start with (empty frontmatter):

---
---

Otherwise the Liquid will not get rendered. That is all!



Answered By - Mr. Hugo
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, July 8, 2022

[FIXED] How to ignore offset in Jekyll when previous post is skipped

 July 08, 2022     jekyll, liquid, offset, posts     No comments   

Issue

I'm trying to create my first blog on Jekyll. I'm stuck on one thing: I have a section for one of my categories, let's say "news":

<section class="news">
    <div class="container">
        <div class="row no-gutters">
        
{% for post in site.categories.news limit: 2 offset: 0 %} 
{% include news-item-col-6.html %}
{% endfor %}

{% for post in site.categories.news limit: 3 **offset: 2** %}
{% include news-item-col-4.html %}
{% endfor %}
            
        </div>
    </div>
</section>

news-item-col-6:

{% if post.thumb != 0 %}
   <div class="col-md-6">
        <div class="pattern">
            <div class="overlay item-title" style="background-image: url({{ post.thumb }});">               
                <div class="item-title-content">
                    <h3><a href="{{ post.url }}">{{ post.header }}</a></h3>                     
                </div>
            </div>      
        </div>
    </div>
{% endif %}

news-item-col-4:

{% if post.thumb != 0 %}
  <div class="col-md-4">
    <div class="pattern">           
        <div class="overlay item-title" style="background-image: url({{ post.thumb }});">
            <div class="item-title-content">
                <h3><a href="{{ post.url }}">{{ post.header }}</a></h3>                 
            </div>
        </div>                  
    </div>
  </div>
{% endif %}

my posts tp

---
layout: post
title: title | site.com
header: title
description: description
categories: categories url
catname: News
image: "images/URL /to image/1.jpg"
thumb: "images/URL /to thumb/1t.jpg"
permalink: "blog/:categories/:year-:month-:day-:slug.html"
---

The problem is that not all of my posts will have background thumb, and all I want to do is to ignore the posts which has no post.thumb. and the code is works, but unfortunately col-md-4 block's offset is not ignoring post's order with no post.thumb.

The pictures below shows what I want:

  • This is how should be, if all my posts have post.thumb(bg_image)
  • This is how should be, if my post Item2 has no post.thumb(bg_image), it just not showing up in section
  • And this is how my code works

So what should I do to make it work right?


Solution

Just use a custom counter, like this:

{% assign counter = 0 %} <!-- create a custom counter and set it to zero -->
{% for post in site.categories.news %} <!-- loop through the posts in news -->
  {% if post.thumb %} <!-- check if the post has a thumbnail -->
    {% assign counter = counter | plus: 1 %} <!-- increment the counter if it does -->
    {% if counter < 3 %} <!-- if this is the first or second counted post -->
      {% include news-item-col-6.html %} <!-- include the col-6 element -->
    {% elsif counter < 6 %} <!-- else -->
      {% include news-item-col-4.html %} <!-- include the col-4 element -->
    {% endif %}
  {% endif %}
{% endfor %}


Answered By - Mr. Hugo
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing