Tutorials
Last updated on:
July 23, 2025

How to add a back button in Webflow

BRIX Templates Logo
Author
BRIX Templates
How to add a back button in Webflow
Article changelog

- Initial version of the article published

Table of contents

Want to add a back button to your thank you or 404 not found page on Webflow? The old solutions found in forums don't work anymore in modern browsers. Our brix-go-back solution works in all cases - it takes users back to the previous page when they navigated from within your site, and automatically redirects to a fallback page (like your homepage) when they came from external sources like Google.

This solution is completely free, weighs only 742 bytes (<1KB), and can be implemented in less than 1 minute.

Implementation

Implement it like this in 3 simple steps:

1. Add the script to your Webflow project

Go to Page SettingsCustom CodeBefore </body> tag and paste this code:

<script>
/**
 * BRIX Templates Back Button
 * Smart back navigation with same-domain detection and fallback support using brix-go-back attribute.
 * @version 1.0.1
 */
(function() {
  'use strict';
  
  function init() {
    document.querySelectorAll('[brix-go-back]').forEach(el => {
      el.addEventListener('click', e => {
        e.preventDefault();
        const fallback = el.getAttribute('brix-go-back') || '/';
        const referrer = document.referrer;
        (referrer && new URL(referrer).hostname === location.hostname && history.length > 1) ? history.back() : location.href = fallback;
      });
    });
  }
  
  document.readyState === 'loading' ? document.addEventListener('DOMContentLoaded', init) : init();
})();
</script>
⁠Add a back button for your Webflow 404 page

Alternatively, you can add this to Project SettingsCustom Code if you need back buttons across multiple pages or site-wide.

2. Add the attribute to your Webflow back button

Add a Button or Link element to your page and in the Element Settings, add the custom attribute:

  • Name: brix-go-back
  • Value: Leave empty for homepage fallback, or specify a custom page like /about or /contact
⁠Add a Webflow back previous page button functionality

3. Publish and test your button

Publish your site and test it. The button will automatically:

  • Go back to the previous page if users navigated from within your site
  • Redirect to your homepage (or specified fallback) if users came from external sources
  • Handle edge cases where no browser history exists

Frequently asked questions

How do I add a back button to my Webflow site?

You can add a back button to your Webflow site by using our free brix-go-back script. Add the lightweight JavaScript code to your project's custom code section, then add a button or link element with the brix-go-back attribute. The script automatically handles same-domain navigation and provides fallback options for external referrers.

How can I create a back button for my Webflow 404 page?

To create a back button for your Webflow 404 page, use our brix-go-back solution. Add the script to your project's custom code, then place a button with the brix-go-back attribute on your 404 page. Set the attribute value to your desired fallback page (like / for homepage) to ensure users who arrive from external links have somewhere useful to go.

How do I add a back button to Webflow thank you pages?

Add a back button to your Webflow thank you pages by implementing our brix-go-back script in your project's custom code, then adding a button with the brix-go-back attribute to your thank you page. This creates smart navigation that works perfectly for form confirmations where users need to navigate back to continue browsing your site.

Want more custom Webflow solutions like this back button implementation? Our Webflow agency builds efficient, lightweight code for navigation, forms, and user experience enhancements that actually work.

BRIX Templates Logo
About BRIX Templates

At BRIX Templates we craft beautiful, modern and easy to use Webflow templates & UI Kits.

Explore our Webflow templates
Join the conversation
Join our monthly Webflow email newsletter!

Receive one monthly email newsletter with the best articles, resources, tutorials, and free cloneables from BRIX Templates!

Webflow Newsletter
Thanks for joining our Webflow email newsletter
Oops! Something went wrong while submitting the form.
How to add next and previous post links in Webflow CMS

How to add next and previous post links in Webflow CMS

Build next/previous post navigation in Webflow CMS with Reference fields or BRIX Post Nav, including sort order logic.

Apr 21, 2026
How to add blog comments to Webflow CMS posts

How to add blog comments to Webflow CMS posts

Add comments to Webflow CMS blog posts with Disqus or Hyvor Talk, ensuring each post has its own discussion thread.

Apr 20, 2026
Webflow Workspace plan vs Site plan: which one do you actually need?

Webflow Workspace plan vs Site plan: which one do you actually need?

Understand Webflow Workspace vs Site plans, when you need each, and how site ownership actually works.

Apr 17, 2026