Hide Links For SEO
Need a link for users but don’t want Google to see it? Render it with data-link and attach a click handler in JS. Clean, simple, and works.
<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)
}
});
}