Outgoing internal links contain nofollow attribute
-
All internal links on our website from the current theme are nofollow. I want my website’s all internal links to be dofollow.
how to do it ? do you have any theme setting ?
Attachments:
You must be
logged in to view attached files.
Hi miniongadgetsbd,
Thanks for reaching to us.
Currently, in order to remove the nofollow attribute, you need to use custom JS, which should be added in Theme settings > Custom JS > Global JS.
document.addEventListener("DOMContentLoaded", function() {
const links = document.querySelectorAll("a[rel~='nofollow']");
links.forEach(link => {
try {
const url = new URL(link.href, window.location.origin);
if (url.hostname === window.location.hostname) {
let rel = link.getAttribute("rel").split(" ")
.filter(r => r.toLowerCase() !== "nofollow");
if (rel.length > 0) {
link.setAttribute("rel", rel.join(" "));
} else {
link.removeAttribute("rel");
}
}
} catch(e) {
}
});
});
Regards,
Hung PD