Liquid, JavaScript, themes, sales channels
Hi, I have a site I need to point to a certain page on the parent site. This site is hosted on Network Solutions which charges to use domain forwarding. I researched how to avoid this charge and went through all steps to forward the domain to the parent site. However, it now points to the home page of the parent site and not the page.
The domain is buttonandsqueaky.com.
The parent site is jimshore.com.
The page I need it to point to is https://jimshore.com/pages/button-and-squeaky-by-jim-shore
Is there a way to point this domain to this page by adding code of some kind in the liquid file(s)?
Thanks,
Margie Reynolds
Hey @mreynolds,
You can use a Shopify app like "Page Redirect" to redirect the buttonandsqueaking.com domain to the specific page on jimshore.com.
You can also add code to your Shopify theme's liquid file to redirect the domain to the specific page. Here is an example of the code you can use:
{% if request.host == 'buttonandsqueaking.com' %}
{% redirect 'https://jimshore.com/pages/button-and-squeaky-by-jim-shore' %}
{% endif %}
This code will check if the host of the current page is 'buttonandsqueaking.com', and if it is, it will redirect to the specific page on jimshore.com. Please, bear in mind that this will redirect all traffic to buttonandsqueaking.com to the specific page, you may want to consider that before proceeding.
Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi Moira,
Would I place this code inside the <head> code or at the bottom above </body>? I just tried placing this in the theme.liquid file above the </head> tag and it threw the following error:
Here is the code I'm placing in the file:
{% if request.host == 'buttonandsqueaky.com/' %}
{% redirect 'https://jimshore.com/pages/button-and-squeaky-by-jim-shore' %}
{% endif %}
The code I provided should be placed in the theme's theme.liquid
file, but it should be placed inside the <head>
section and not above it. The </head>
tag is the end of the head section, so any code placed above it would not be executed.
Regarding the error message "Unknown tag 'redirect'" it seems that the 'redirect' is not a valid liquid tag, I apologize for my previous response,
A possible solution would be to use a javascript redirect instead. You can add the following code to your theme's theme.liquid
file, inside the <head>
section:
{% if request.host == 'buttonandsqueaking.com/' %}
<script>
window.location.href = "https://jimshore.com/pages/button-and-squeaky-by-jim-shore";
</script>
{% endif %}
This will check if the host of the current page is 'buttonandsqueaking.com', and if it is, it will use javascript to redirect the user to the specific page on jimshore.com. Please, bear in mind that this will redirect all traffic to buttonandsqueaking.com to the specific page, you may want to consider that before proceeding.
Moira | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
User | RANK |
---|---|
21 | |
21 | |
10 | |
7 | |
6 |
Explore the 30-30-30 rule, a dynamic social media strategy for new businesses. Learn how t...
By Trevor Sep 20, 2023Discover how to leverage the often overlooked footer of your ecommerce site to gain custom...
By Skye Sep 15, 2023In this blog, we’ll be shining a light on Shopify Partners, Experts, and Affiliates. Who a...
By Imogen Sep 13, 2023