0
votes

The liquid tags on the homepage of my website are not expanding (see the description tag, specifically):

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- If the post has an empty title (because it's a "short") then don't add it to the title of the page. -->
    <title>Alex Learns Programming</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="{% for post in paginator.posts %} {{ post.date | date: site.date_format }} {{ post.title }} {% if post.summary %} {% if post.image %} {% endif %} {{ post.summary }} Read more &#8594; {% elsif post.content contains site.excerpt_separator %} {{ post.excerpt }} Read more &#8594; {% else %} {{ post.content }}...">
    <meta name="author" content="Alex Johnson">

    <link rel="canonical" href="http://code.alxmjo.com/">
    <link rel="alternate" type="application/rss+xml" title="RSS Feed for Alex Learns Programming" href="/feed.xml" />
    ...

However, on posts the liquid tags expand just fine:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- If the post has an empty title (because it's a "short") then don't add it to the title of the page. -->
    <title>Insitu: Week Five &#8211; Alex Learns Programming</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Today I finish my fifth week at Insitu. I was supposed to be on a bus headed out to watch a test flight today, but that trip was postponed because of a nearby wildfire. So instead I’m sitting in my usual coffee shop in White Salmon, thinking back on the...">
    <meta name="author" content="Alex Johnson">
    <meta name="keywords" content="Insitu">

    <link rel="canonical" href="http://code.alxmjo.com/insitu-week-five">
    <link rel="alternate" type="application/rss+xml" title="RSS Feed for Alex Learns Programming" href="/feed.xml" />
    ...

Based on my research, I know that YAML frontmatter is required for Liquid tags to expand properly. But I believe I have them in the correct places.

I'm not sure if it's relevant to this question but here are the files I believe to be involved in this issue:

For what it's worth, this is a mostly stock, up-to-date Jekyll install.

Any idea what I've done wrong here?

1

1 Answers

0
votes

The problem was with this line in _includes/head.html:

<meta name="description" content="{% if page.summary %}{{ page.summary | strip_html | strip_newlines }}{% else %}{{ page.content | strip_html | truncatewords: 50 }}{% endif %}">

There was no summary for the homepage, so it was going to the second part of the if statement and just pulling in the page's content. That happened to be raw Liquid, hence how it was showing up above.

Fixed this by modifying that line to the following:

<meta name="description" content="{% if page.url == "/" %}{{ site.description }}{% elsif page.summary %}{{ page.summary | strip_html | strip_newlines }}{% else %}{{ page.content | strip_html | truncatewords: 50 }}{% endif %}">

A bit cumbersome, but it does the trick.