Marketing 3 min read

How to Ensure Links Work Properly With JavaScript

TierneyMJ / Shutterstock.com

TierneyMJ / Shutterstock.com

Like many other in-person events, the Google Webmaster conferences were canceled due to the coronavirus pandemic.

But to ensure that people get their regular dose of SEO info, the tech giant brought its advocates together in a new video series called Webmaster Conference Lightning Talks. It’s a short version of the presentations that the Google advocates would have shared in the canceled conferences.

The talk series covers various topics, and Google intends to publish the videos throughout the year.

In its first episode, Martin Splitt explored the dos and don’ts of links and JavaScript in SEO.

Splitt points out that creating a link is not a straightforward process, especially when including JavaScript functionality to the link. Although Javascript can enable you to customize your links in various ways, it could also render the link unusable to crawlers.

So, what do you do?

The Right Ways to Apply JavaScript to Links for SEO

1. Keep Your Links Straightforward

Martin Splitt recommends the most straightforward methods of creating links. And that’s using the HTML tag with the destination URL in the ahref attribute.

You can also add JavaScript to a link to upgrade its functionality. However, it must meet specific conditions first.

2. Don’t Leave Out the Ahref Attribute

As tempting as it may be to remove the ahref attribute and “clean up” your code, don’t do it. According to Splitt, doing so means that the link will only work if the JavaScript also functions properly.

Crawlers can only access content using an ahref attribute. So if the attribute is absent, the bots will not be able to determine where a link goes to. Splitt also points out that it’s also a bad idea to add an ahref attribute with a pseudo URL.

3. Beware of Fragment Identifiers

You can distinguish a fragment identifier within a URL by the “#” symbol, and when it points to a subsection of a given page. For example, domainname.com/FAQ#subsection would take you to a specific point on the page domainname.com/FAQ.

Now, here’s the problem.

Because fragments aren’t meant to point to different content, crawlers ignore them; they just pretend that the fragments don’t exist,” Splitt said

That means if you build a single page application using links full of fragment identifiers, crawlers will not follow the links.

Watch the full video here:

Read More: Google Explains Why Infinite Scroll Causes SEO Problems

First AI Web Content Optimization Platform Just for Writers

Found this article interesting?

Let Edgy Universe know how much you appreciate this article by clicking the heart icon and by sharing this article on social media.


Profile Image

Edgy Universe

EDGY is an SEO incubator, forecaster, and support center for deep learning, technological advancement, and enterprise-level end-to-end search programs.

Comments (0)
Most Recent most recent
You
share Scroll to top

Link Copied Successfully

Sign in

Sign in to access your personalized homepage, follow authors and topics you love, and clap for stories that matter to you.

Sign in with Google Sign in with Facebook

By using our site you agree to our privacy policy.