Add link into blog.liquid

Bamboo_Lulu
New Member
2 0 0

Hi

I need some help please on where I can add a link on my blog.liquid that encourages people to sign up to my newsletter.

It would be at the end of the blog.

This is the script:

% paginate blog.articles by 5 %}

<div class="grid">
 
  <div class="grid__item post-large--four-fifths">
   
    <div class="grid">
      <div class="grid__item post-large--ten-twelfths">

        {% comment %}{% include 'breadcrumb' %}{% endcomment %}
        <header class="section-header">
          <h1 class="section-header__title h3">
            {% if current_tags %}
              {{ blog.title | link_to: blog.url }} &mdash; {{ current_tags.first }}
            {% else %}
              {{ blog.title }}
            {% endif %}
          </h1>
        </header>

        {% for article in blog.articles %}

          <h2><a href="{{ article.url }}">{{ article.title }}</a></h2>
          <p class="blog-date">
            <time datetime="{{ article.published_at | date: '%Y-%m-%d' }}">{{ article.published_at | date: format: 'month_day_year' }}</time>
            {% if settings.blog_author_enable %}
              <span class="meta-sep">&#8226;</span>
              {{ article.author }}
            {% endif %}     
                  {% if article.tags.size > 0 %}
            {% if article.content contains "<img" %}
  {% assign src = article.content | split: 'src="' %}
  {% assign src = src[1] | split: '"' | first | replace: '//cdn', 'http://cdn'; | replace: 'http:http://';, 'http://'; | remove: 'https:' %}

  <img src="{{ src }}" alt="{{ article.title }}" />
       
{% endif %}
              <span class="meta-sep">&#8226;</span>
              {% for tag in article.tags %}
                <a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ tag }}</a>{% unless forloop.last %} <span class="meta-sep">&#8226;</span> {% endunless %}
              {% endfor %}
            {% endif %}
          </p>

          {% comment %}
            Add a surrounding div with class 'rte' to anything that will come from the rich text editor.
            Since this is just a listing page, you can either use the excerpt or truncate the full article.
          {% endcomment %}
          <div class="rte">
            {% if article.image %}
              {% assign image_alt = article.title | escape %}
              <p>{{ article | img_url: '1024x1024' | img_tag: image_alt, 'article__image' | link_to: article.url }}</p>
            {% endif %}
            {% if article.excerpt.size > 0 %}
              {{ article.excerpt }}
            {% else %}
              <p>{{ article.content | strip_html | truncatewords: 100 }}</p>
            {% endif %}
          </div>

          <p><a href="{{ article.url }}">{{ 'blogs.article.read_more' | t }} &rarr;</a></p>

          {% unless forloop.last %}<hr>{% endunless %}

        {% endfor %}

        {% if paginate.pages > 1 %}
          <div class="text-center">
            {% include 'pagination-custom' %}
          </div>
        {% endif %}
      </div>
    </div>   
  </div>

  <aside class="sidebar grid__item post-large--one-fifth">
    {% include 'blog-sidebar' %}
  </aside>
 
</div>

{% endpaginate %}

0 Likes
dav-mcg
Shopify Staff
Shopify Staff
103 0 29

Hey Lulu,

David here, Shopify Guru!

To include a newsletter link at the end of individual blog posts you would need to insert the code in the article.liquid rather than the blog.liquid. So if you would like a newsletter form at the end you could insert this snippet:

<h3>Subscribe to our Newsletter!</h3>
{% include 'newsletter-form' %}

to line 39 of the article.liquid file.

If you would rather this appear on the blogs page which displays all your blogs, you can insert the same snippet to line 72 of your blog.liquid like so:

Hope that helps, feel free to drop us a line at support@shopify.com if you have any other questions :)

David Mc | Shopify Guru

0 Likes
Bamboo_Lulu
New Member
2 0 0

Perfect thank you

0 Likes
Mdaniels21
New Member
2 0 0

Hello, does this advice still work?

0 Likes