---
title: Online store customer login redirects
description: Learn how to direct customers to different pages on the online store after they login.
source_url:
html: https://shopify.dev/docs/storefronts/themes/login
md: https://shopify.dev/docs/storefronts/themes/login.md
---
ExpandOn this page
* [Resources](https://shopify.dev/docs/storefronts/themes/login#resources)
* [Redirecting to customer accounts](https://shopify.dev/docs/storefronts/themes/login#redirecting-to-customer-accounts)
* [Direct customers back to the online store](https://shopify.dev/docs/storefronts/themes/login#direct-customers-back-to-the-online-store)
* [Direct customers back to another page on the online store](https://shopify.dev/docs/storefronts/themes/login#direct-customers-back-to-another-page-on-the-online-store)
# Online store customer login redirects
You can configure where customers are redirected after they log in to their account on your store. For example, you might want to redirect customers to the page they were on when they logged in, or a specific product collection.
In this tutorial, you'll learn how to configure custom redirects in your theme.
***
## Resources
Use [`routes` object](https://shopify.dev/docs/api/liquid/objects/routes) to manage login redirection.
***
## Redirecting to customer accounts
Before you edit your theme code, review the [considerations for customizing your theme](https://help.shopify.com/manual/online-store/themes/customizing-themes#before-you-customize-your-theme) to prevent any unintended changes to your store.
In Liquid, the [`routes`](https://shopify.dev/docs/api/liquid/objects/routes) object can be used to direct customers to customer accounts, where they can view their order history and track current orders:
* **`routes.account_login_url`**: Takes customers to the login screen and then to the order index page after a successful login
* **`routes.account_url`**: Takes customers to customer accounts order index page directly
If you need to append a path (such as for an account extension, tab, or subpage) to `routes.account_url`, be aware that this URL may sometimes contain query parameters (for example, after a successful login).
To ensure your generated links remain valid, always split `routes.account_url` on the `?` character before appending your extension, then re-attach any query parameters at the end.
Example:
## /sections/header.liquid
```liquid
{% assign url_parts = routes.account_url | split: '?' %}
{% assign base_url = url_parts | first %}
Account Extension Link
```
This approach always produces a valid link, regardless of whether `routes.account_url contains` query parameters.
### Modify your login links to redirect to the order index page
If your store's theme supports a customer account login link, then the following is an example of the default route on the `header.liquid` page:
## /sections/header.liquid
```liquid
{%- if shop.customer_accounts_enabled -%}
{%- endif -%}
```
If your theme doesn't display a login link in your theme header, then you can add a customer account login link to your theme with the following Liquid code:
## /sections/header.liquid
```liquid
{%- if shop.customer_accounts_enabled -%}
{% if customer %}
Account
{% else %}
Login
{%- endif %}
{%- endif -%}
```
### Link directly to customer account pages
Create direct links to redirect customers to specific customer account pages, such as their **Profile** page:
## /sections/header.liquid
```liquid
{% assign url_parts = routes.account_url | split: '?' %}
{% assign base_url = url_parts | first %}
Account Profile
```
Link to a customer account full-page extension with the following Liquid code:
## /sections/header.liquid
```liquid
{% assign url_parts = routes.account_url | split: '?' %}
{% assign base_url = url_parts | first %}
Account Extension
```
***
## Direct customers back to the online store
Direct your customers back to the online store after successful login by editing your theme code to use the [`routes.storefront_login_url`](https://shopify.dev/docs/api/liquid/objects/routes#routes-storefront_login_url) object. Once logged in, the customer will be taken back to the page where the login originated. For example, if a customer is on the Catalogs page and clicks on the login link, they will be taken back to Catalogs after a successful login.
The following example demonstrates how you can modify the customer account login link with the `storefront_login_url` route. In this example, after a customer logs in, they will be taken back to the storefront. If they click on the login link again, they will be taken to customer accounts:
## /sections/header.liquid
```liquid
{%- if shop.customer_accounts_enabled -%}
{%- endif -%}
```
You can also add the route to any login URL on your storefront with the following Liquid code:
## /sections/header.liquid
```liquid
Login
```
Note
If you choose to direct customers back to the online store after login by replacing the default login link route, we recommend you use another link on your theme that navigates customers to their accounts/orders.
***
## Direct customers back to another page on the online store
You can redirect customers to any page on your online store using the `/customer_authentication/login` path with a `return_to` parameter.
For example, to redirect customers to your **Contact** page after login, use this Liquid code:
## /sections/header.liquid
```liquid
Contact
```
Note
The `return_to` parameter will only work with relative URLs.
***
* [Resources](https://shopify.dev/docs/storefronts/themes/login#resources)
* [Redirecting to customer accounts](https://shopify.dev/docs/storefronts/themes/login#redirecting-to-customer-accounts)
* [Direct customers back to the online store](https://shopify.dev/docs/storefronts/themes/login#direct-customers-back-to-the-online-store)
* [Direct customers back to another page on the online store](https://shopify.dev/docs/storefronts/themes/login#direct-customers-back-to-another-page-on-the-online-store)