Current Shopify Page URL For Blog Page Tagged View

- 1 answer

I have replaced the Shopify signup form by a GetResponse form and I want the page to stay in the same place after the form is submitted. For that I am trying to dynamically generate the current URL so that I can pass it as the return URL. Here’s what my code snippet looks like:

    {% assign current_url = '' %}

    {% case template %}
         {% when 'page' %}
               {% assign current_url = page.url %}
         {% when 'blog' %}
               {% assign current_url = blog.url %}
         {% when 'article' %}
               {% assign current_url = article.url %}
         {% when 'collection' %}
               {% assign current_url = collection.url %}
         {% when 'product' %}
               {% assign current_url = product.url %}
    {% endcase %}

<form action="" accept-charset="utf-8" method="post">
<!-- Show the name field (required) -->
<input type="hidden" name="name"/>
<!-- Email field (required) -->
<input type="text" name="email"/>

<!-- Campaign token -->
<!-- Get the token at: -->
<input type="hidden" name="campaign_token" value="xxxxx"/>

<!-- Subscriber button -->
<input type="submit" value="Sign Me Up" onclick="javascript:window.alert('Thanks for entering your email address!');"/>
<!-- Add any optional code here (explained below) -->
<input type="hidden" name="thankyou_url" value="{{ current_url }}"/>

As you can see in the case statements I have taken care of all the page types separately. When the user is in the main blog page (, blog.url correctly returns /blogs/news. However when I click on any of the tags, I go to the URL line or So I am trying to get my code to handle this case as well so that current_url gets the value /blogs/news/tagged/diy or /blogs/news/tagged/bizarre etc.

If there’s no single variable that returns it that’s OK too. I just need a way to return the tag value (like diy or bizarre). Then I can concatenate blog.url + /tagged/ +

Is this possible?



You can do this using current_tags. Refer

A simple change in your code will be like this

{% capture current_url %}
  {% case template %}
    {% when 'page' %}{{page.url}}
    {% when 'blog' %}{% if current_tags %}/{{ current_tags.first | handleize }}{% endif %}
    {% when 'article' %}{{article.url}}
    {% when 'collection' %}{{collection.url}}{% if current_tags %}/{{ current_tags.first | handleize }}{% endif %}
    {% when 'product' %}{{product.url}}
  {% endcase %}
{% endcapture %}

<input type="hidden" name="thankyou_url" value="{{ current_url | strip_newlines }}" />