3

If I direct my website pages via JavaScript (not links), will my pages become Orphan Pages? Because we have website filters that would like to move the functionality by API call.

2
  • By "direct your website" do you mean that users clicking between pages will be handled by JavaScript without using classic <a href=...> links? Nov 20, 2021 at 23:42
  • Yes @StephenOstermiller
    – Jeric C
    Nov 20, 2021 at 23:44

2 Answers 2

5

According to this post from SeoProfiler JavsScript can be problemetic. They cite John Mueller of Google (and an occasional contributor here).

If your website uses JavaScript links, not all pages of your website might be indexed by Google. In general, your website should not rely on JavaScript.

They provide the following four examples of hyperlinks and whether Google would typically crawl them.

This is a regular a href link that will be crawled by Google.

<a href="/good-link">Will be crawled</a>

Google will not crawl this link because it is not an anchor.

<span onclick="changePage('bad-link')">Not crawled</span>

This link is in an anchor, but it does not use the href attribute. That’s why Google won’t crawl it.

<a onclick="changePage('bad-link')">Not crawled</a>

This link will be crawled by Google because it is an anchor with a href attribute.

 <a href="/good-link" onclick="changePage('good-link')">Will be crawled</a>

While Google can crawl JavaScript, it seems the problem lies in the format of the link. If your API doesn't present something that Google will recognize as a link, it's a strong possibility that Google will not be able to traverse your files.

1
  • 1
    Use real links! Fake links (like that span) are impossible for some users to navigate, namely those who use a keyboard or especially a screenreader. (This isn't a coincidence; Googlebot works similarly.) And you'll annoy people like me who want to shift+click or drag and drop or right click on the "link".
    – Laurel
    Nov 21, 2021 at 21:35
2

If you don't use <a href=...> links, Googlebot will not be able to crawl your site. All of your pages will look like orphan pages to search engines.

It is fine to handle navigation with JavaScript, as long as you use regular links that are visible to search engines. You would typically do something like:

<a href=foo.html onclick="load('foo');return false">

From that, search engines can find links to foo.html while users only execute the JavaScript. Returning false from the onclick handler prevents default action specified by the href from happening for users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.