SEO - Image Alt Tags - special characters HTML

JohnJ
Explorer
56 1 21

Hello together,

I want to set Image Alt Tags for my shop. I plan to use an application to do it in a bulk.
My problem is that I use HTML (<br/>) in my product titles for word wrapping. Now I would like to use the product titles as an element in my image alt tags.
But as special characters are not good for SEO, I think it's not a good idea to have this HTML <br/> in my image alt tags. But with the app I'm using, the only way would be to delete the HTML from the product description.

Now my question to you. Is there any SEO app out there, that magically miss out the HTML in my product titles?
Or does anyone has a better idea (or app) to add image alt tags, without writing tags one by one for every image?

YFI, I'm pretty new to SEO.
Thank you in advance.

0 Likes
KieranR
Shopify Partner
134 10 35

Personally don't think it's that big of a concern.

However, one way to do what you're asking is to modify your theme liquid to use the strip_html filter

So instead of this:

 

{% for image in images %}
  <img src="{{ image.src }}" alt="{{ image.alt }}" />
{% endfor %}

 

 

Do this: 

 

 

 

{% for image in images %}
  <img src="{{ image.src }}" alt="{{ image.alt | strip_html }}" />
{% endfor %}

 

A self defined Shopify SEO "expert". Sometimes I freelance outside the 9-5
JohnJ
Explorer
56 1 21

Thank you very much for the input! I got two questions, would be nice if you could answer them

-If I use the strip_html filter in relation to image.alt, it will remove the HTML tags just from the image alt tags? The HTML tags in the product descriptions will remain?

-And regarding the code. After I create image alt tags, I will find the following code in my liquid file?
2021-02-02 20_27_30-Reply to Message - Shopify Community – Opera.png
And then I change it to this?
2021-02-02 20_29_41-Reply to Message - Shopify Community – Opera.png

Thank you for your help. I'm a real newby to this.

KieranR
Shopify Partner
134 10 35

Hmm actually looking at this would have to test this irl. You can save HTML into Alt fields in Shopify admin, however when it gets output it's being escaped. Depends on the order Shopify runs their HTML escaping if it's before or after any filters applied.

But the example I gave is really just generic psuedo-code your implementation would be theme specific.

It might turn out easier to drop the <br> tags at the bulk upload phase, is that possible? 

A self defined Shopify SEO "expert". Sometimes I freelance outside the 9-5
JohnJ
Explorer
56 1 21

@KieranR wrote:

It might turn out easier to drop the <br> tags at the bulk upload phase, is that possible? 


This was my first thought  when I faced this issue. So I reached out to the support team of the app that I plan to use (Vitals).
But they say that's not possible with their app. That's why I've posted my question here in the forum.

Mabe there is another SEO app out there, that can drop HTML tags during the bulk upload phase.
Sadly I wasn't able to find any information about this. Doesn't seem to be a usual feature.

0 Likes
Crooker4562
New Member
1 0 0

ALT tags however, are typically recognized. You'll notice a lot of images can be searched on by the alt text. This also has limits-- too much text -> treat as spam. So in short, it depends on how the search engine interprets the users search terms so that it can return relevant/accurate results.

 

Official Site

 

 

0 Likes