To redirect your Webflow website to a specific URL based on user language, you’ll need to use custom JavaScript since Webflow doesn’t support language redirects natively.
1. Use the Navigator Language API
- The browser exposes the user’s language via
navigator.language
or navigator.languages
. - You can use this to determine the visitor’s preferred language and redirect them accordingly.
2. Add Custom Code in Webflow
- Go to Project Settings > Custom Code > Footer Code.
- Add a script that runs on page load and checks the language.
Example logic (don’t paste raw code, just the behavior):
- Detect if the browser language starts with "fr", then redirect to your French site (e.g.,
example.com/fr
). - If it starts with "es", redirect to
example.com/es
, and so on. - For all other languages or fallbacks, redirect to the default homepage.
3. Prevent Redirect Loop
- Only run this script on the root domain (like
example.com
) and not on already localized URLs (example.com/fr
, etc.). - You can check the current
window.location.pathname
and exit early if it's already a subpath.
4. Use with Webflow Hosting Structure
- Make sure your language-specific pages or folders (e.g.,
/fr
, /es
) exist in Webflow. - These can be created as folders with their own homepage (
index.html
inside folder).
5. Optional: Use a Cookie to Avoid Repeated Redirects
- Use JavaScript to set a cookie after the first redirect.
- Check that cookie before redirecting again, avoiding unnecessary bounce for return users.
Summary
To redirect users to a language-specific URL in Webflow, inject a JavaScript snippet using the Navigator Language API via Project Settings > Footer Code. Build conditional logic to check the user's language, redirect to the appropriate localized path, and ensure you avoid infinite loops by targeting only the root URL.