Add a continue shopping link to your cart

You can add a Continue shopping link to your cart page that allows customers to quickly return to browsing products after adding something to the cart. You can choose to add a link that will take customers back to your catalog page, back to your home page, or back to the last collection page that they were looking at.

Continue shopping

Desktop
  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, click the button to open the actions menu, and then click Edit code.
  3. In the Sections directory, click cart-template.liquid. If your theme doesn't have this file, then click cart.liquid in the Templates directory.
  4. Find the code for the Checkout button by searching the file for name="checkout". The line of code for the checkout button varies theme to theme, but will look something like this:
<button type="submit" id="checkout" name="checkout" class="btn">
   {{ 'cart.general.checkout' | t }}
</button>

 5. The next step is to paste a new line of code to create a Continue shopping link. The code that you paste will depend on which page you would like the link to go to: * To add a link that goes to your catalog page, paste the following code on a new line either before or after the code for the Checkout button:

<a href="/collections/all" title="Continue shopping">Continue shopping</a>
  • To add a link that goes to your home page, paste the following code on a new line either before or after the code for the Checkout button:
<a href="/" title="Continue shopping">Continue shopping</a>
  • To add a link that goes to the last collection viewed, paste the following code on a new line either before or after the code for the Checkout button:
<a
  id="continue-shopping"
  href=""
  title="Continue shopping">
  Continue shopping
</a>

 6. Click Save. If you added a link that goes to either your catalog page or your home page, then you are done. If you added a link that goes to the last collection viewed, then you will need to add some JavaScript to your theme code. Continue to follow the next steps.

 7. In the Layout directory, click theme.liquid.

 8. Find the closing </body> tag, near the bottom of the file. Paste the following code above the closing </body> tag:

<script>
  if(Storage !== undefined) {

    var defaultLink = "/collections/all";

    {% if template contains 'collection' %}
      sessionStorage.collection = "{{ collection.url }}";
    {% endif %}

    {% if template contains 'cart' %}
      if( !sessionStorage.collection ) {
        sessionStorage.collection = defaultLink;
      }
      document.getElementById("continue-shopping").href = sessionStorage.collection;
    {% endif %}

    }
</script>

 9. Click Save.

iPhone
  1. From the Shopify app, tap the button.
  2. In the Sales channels section, tap Online Store.
  3. Tap Manage themes.
  4. Find the theme you want to edit, click the button to open the actions menu, and then click Edit code.
  5. In the Sections directory, click cart-template.liquid. If your theme doesn't have this file, then click cart.liquid in the Templates directory.
  6. Find the code for the Checkout button by searching the file for name="checkout". The line of code for the checkout button varies theme to theme, but will look something like this:
<button type="submit" id="checkout" name="checkout" class="btn">
  {{ 'cart.general.checkout' | t }}
</button>
  1. The next step is to paste a new line of code to create a Continue shopping link. The code that you paste will depend on which page you would like the link to go to:
    • To add a link that goes to your catalog page, paste the following code on a new line either before or after the code for the **Checkout* button:
<a href="/collections/all" title="Continue shopping">Continue shopping</a>
  • To add a link that goes to your home page, paste the following code on a new line either before or after the code for the Checkout button:
<a href="/" title="Continue shopping">Continue shopping</a>
  • To add a link that goes to the last collection viewed, paste the following code on a new line either before or after the code for the Checkout button:
<a
  id="continue-shopping"
  href=""
  title="Continue shopping">
  Continue shopping
</a>
  1. Click Save. If you added a link that goes to either your catalog page or your home page, then you are done. If you added a link that goes to the last collection viewed, then you will need to add some JavaScript to your theme code. Continue to follow the next steps.
  2. In the Layout directory, click theme.liquid.
  3. Find the closing </body> tag, near the bottom of the file. Paste the following code above the closing </body> tag:
<script>
  if(Storage !== undefined) {

    var defaultLink = "/collections/all";

    {% if template contains 'collection' %}
      sessionStorage.collection = "{{ collection.url }}";
    {% endif %}

    {% if template contains 'cart' %}
      if( !sessionStorage.collection ) {
        sessionStorage.collection = defaultLink;
      }
      document.getElementById("continue-shopping").href = sessionStorage.collection;
    {% endif %}

    }
</script>
  1. Click Save.
Android
  1. From the Shopify app, tap the button.
  2. In the Sales channels section, tap Online Store.
  3. Tap Manage themes.
  4. Find the theme you want to edit, click the button to open the actions menu, and then click Edit code.
  5. In the Sections directory, click cart-template.liquid. If your theme doesn't have this file, then click cart.liquid in the Templates directory.
  6. Find the code for the Checkout button by searching the file for name="checkout". The line of code for the checkout button varies theme to theme, but will look something like this:
<button type="submit" id="checkout" name="checkout" class="btn">
  {{ 'cart.general.checkout' | t }}
</button>
  1. The next step is to paste a new line of code to create a Continue shopping link. The code that you paste will depend on which page you would like the link to go to:
    • To add a link that goes to your catalog page, paste the following code on a new line either before or after the code for the **Checkout* button:
<a href="/collections/all" title="Continue shopping">Continue shopping</a>
  • To add a link that goes to your home page, paste the following code on a new line either before or after the code for the Checkout button:
<a href="/" title="Continue shopping">Continue shopping</a>
  • To add a link that goes to the last collection viewed, paste the following code on a new line either before or after the code for the Checkout button:
<a
  id="continue-shopping"
  href=""
  title="Continue shopping">
  Continue shopping
</a>
  1. Click Save. If you added a link that goes to either your catalog page or your home page, then you are done. If you added a link that goes to the last collection viewed, then you will need to add some JavaScript to your theme code. Continue to follow the next steps.
  2. In the Layout directory, click theme.liquid.
  3. Find the closing </body> tag, near the bottom of the file. Paste the following code above the closing </body> tag:
<script>
  if(Storage !== undefined) {

    var defaultLink = "/collections/all";

    {% if template contains 'collection' %}
      sessionStorage.collection = "{{ collection.url }}";
    {% endif %}

    {% if template contains 'cart' %}
      if( !sessionStorage.collection ) {
        sessionStorage.collection = defaultLink;
      }
      document.getElementById("continue-shopping").href = sessionStorage.collection;
    {% endif %}

    }
</script>
  1. Click Save.

Add button styling (optional)

If you use a free Shopify theme, then you can apply styling to your Continue shopping link to make it look like a button. By adding a class attribute to the code for your button link, you can make your button match the style of the other buttons in your theme. All free Shopify themes use the same class name for primary button styles, and most use the same class name for secondary button styles.

Add the attribute class="btn" to the line of code that you pasted to add a Continue shopping link. Your code should look like this:

<a href="/collections/all" title="Continue shopping" class="btn">
  Continue shopping
</a>

If you use a free theme that isn't Supply, then add the attribute class="btn--secondary" to the line of code that you pasted to add a Continue shopping link. Your code should look like this:

<a href="/collections/all" title="Continue shopping" class="btn--secondary">
  Continue shopping
</a>

If you use Supply, then add the attribute class="btn-secondary" to the line of code that you pasted to add a Continue shopping link. Your code should look like this:

<a href="/collections/all" title="Continue shopping" class="btn-secondary">
  Continue shopping
</a>
Can’t find the answers you’re looking for? We’re here to help.