Hide Links For SEO

If you ever need to have a link on a page for usability, but don’t want it visible to Google… here’s a confirmed working method.

<span class="not-a-link" data-link="https://example.com/target">Test</a>
const x = document.querySelectorAll(".not-a-link");
let i;

for(i = 0; i < x.length; i++) {
	x[i].addEventListener("click", function () {
		try {
			window.location.href = this.getAttribute("data-link")
		} catch (e) {
			console.log(e)
		}
	});
}
© 2014 - 2021 · Home ·