Navigation via HTML or Javascript

Asked

Viewed 816 times

7

I’ve been working a lot with javascript and it makes me use it for almost everything. But I’m having a question.

Is there any problem of 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>

  • 1

    I believe that the second option is the best, is clearer for SEO. What’s more, adding Rigger by the class of an element to something unique, like accessing a particular page, is not cool, use ID for it. $('#test 1)....

1 answer

4


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

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

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

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

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

Ex: Several places 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 within paragraphs.

In your case:

HTML:

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

Javascript/jQuery:

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

The search site indexer may never index this link. Only if the indexer also scans javascript for fragments location.href.

HTML:

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.