Repository navigation
Quotes in Shopify product titles break custom HTML? Escape text at output #25
vistabylara-dev
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
إذا كسرت علامات الاقتباس اسم منتج داخل رابط مخصص، فقد يكون السبب إخراج النص دون ترميز مناسب. المثال التالي يحمي حدود خصائص HTML ويُبقي النص واضحاً.
Free Shopify code series · 22/50 · Reviewed 24 October 2026
The problem and suggested fix
A custom link works for ordinary product names but breaks when a title contains quotation marks, an ampersand, or angle brackets. Escape plain text where it enters HTML, and quote attribute values. The example uses Shopify's product URL rather than building one from the title.
Before editing
Duplicate your theme and work in the unpublished copy. Save the original files. This is a bounded code suggestion, not a universal theme repair. Keep the live store unchanged until preview checks pass.
Placement
Use this fragment in an existing product-template section of a duplicate theme, where product is the current product. It demonstrates a custom product link. Keep your theme's existing classes and behavior when adapting it; do not replace the whole product section. For a collection card, substitute the actual product variable used by that card.
Liquid fragment — not a replacement for the full section:
{% if product != blank %} <a href="{{ product.url | escape }}" aria-label="{{ product.title | escape }}" > {{ product.title | escape }} </a> {% endif %}Applicability and limits
escape is for HTML text and quoted attributes. It is not JavaScript serialization, URL scheme validation, or a general sanitizer for arbitrary HTML. Do not remove escaping simply to make raw markup execute. A product description or rich-text setting may intentionally contain formatted HTML and needs a different, context-aware treatment. Store plain text as plain text, not pre-escaped entities.
Check before publishing
On a development product, try a title with double quotes, an ampersand and literal angle brackets. The link text and accessible name should match the intended title; the element should remain one link with an intact href. Check keyboard use, mobile wrapping and translated titles. Inspect the rendered DOM for unexpected attributes or extra elements. Restore the test product's original title after checking.
Validation: The Liquid fragment passed Shopify's validation tool. No live merchant store was changed. Rendering, theme integration and commercial results have not been tested.
Rollback
Restore the original markup from your saved copy and remove only the translation keys introduced by this example if no longer used. If you published a modified theme and notice regressions, return to the saved working theme while diagnosing the cause.
Get help with your own store
Send Dr Lara your store URL, theme name, affected page and the change that preceded the problem. Start with free guidance and a free initial consultation. If you need implementation, the scope and fee are agreed separately before work starts.
Explore Shopify theme repairs and development with Vista by Lara
WhatsApp Dr Lara about this guide or call +971 50 799 4292.
Free guidance. No commitment. Practical implementation is separately scoped.
Share your experience
Did the problem start after a theme edit, an app installation, or a language change? Share a short sanitized example. Do not post passwords, tokens, customer data or private admin links.
Official references
Dr Lara · Vista by Lara · Dubai, UAE
All reactions