Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello everyone,
I'm new to shopify.
I have an issue related to hash.
I'd like to get a hash string in current page.
I tried it, but it didn't work
Codes I wrote is below
・a page before transition
In this, page, I added an original hash to href of an a tag.
For example . the url will be /pages/lookbook#abc if collection.metafields.custom.title is abc.
{% assign hash = collection.metafields.custom.title | handleize %} {% assign url = pages["lookbook"].url | append: "#" | append: hash %} <a href="{{ url }}" class="page-collection__card"> <div class="page-collection__box">
... </div> </a>
・a page after transition
I wrote this codes cause I want to confirm what url I can see.
The result was "/pages/lookbook". This didn't include "#abc"
{{ page.url }}
However, url of display showed "http://~/pages/lookbook#abc".
In addition, I wrote blew a code and the resulted "#abc".
console.log(location.hash)
I need someone to tell me the reason.
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025