Navigation via HTML or Javascript

8

I've been working hard with javascript and it makes me use it for almost everything. But I have a question.

Is there any problem with semantics, indexing or search results of my page when I use:

HTML: <img class="teste" src="img.pjg">

Javascript / jQuery: $('.teste').click(() => window.location.href = 'pagina.html');

Instead of using:

HTML: <a href="pagina.html"><img src="img.pjg"></a>

    
asked by anonymous 11.01.2017 / 14:01

1 answer

5

Yes, there are indexing issues when using javascript for links.

Search engines navigate the site by following the anchors and saving the text that was used in them. If you use javascript navigation not all crawlers will have enough intelligence to be able to follow the links on your page, maybe Google has already worked on something like this, but normal link usage is much more guaranteed.

In order of what is most valuable to a search engine, it follows:

1) A url. Ex: www.palavrachave.com or www.seusite.com/palavrachave

2) The text of the anchor. The more posts using keyword in the page anchor, the more relevant the url is linked. If the link is an image, use alt or title.

Ex: Multiple posts linking to <a href="http://www.bolosdatiateteca.com">Tia Teteca - Bolos de aniversário</a> in a search for " Birthday cakes " is much more relevant than <a href="http://www.bolosdatiateteca.com">bolosdatiateteca.com</a>

3) The title of the page.

4) The text of tags h1, h2 and h3.

5) The text inside paragraphs.

In your case:

HTML:

<img class="teste" src="img.pjg">

Javascript / jQuery:

$('.teste').click(() => window.location.href = 'pagina.html');

The search engine crawler can never crawl this link. Only if the indexer also sweeps javascript looking for location.href fragments.

HTML:

<a href="pagina.html"><img src="img.pjg"></a>

In this case, you have the link being indexed right away. Put an alt in the image and this link will become more relevant to search engines.

    
26.01.2017 / 12:46