Home Forums WoodMart support forum Outgoing internal links contain nofollow attribute

Outgoing internal links contain nofollow attribute

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #689507

    miniongadgetsbd
    Participant

    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.
    #689599

    Hung Pham
    Participant

    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

Viewing 2 posts - 1 through 2 (of 2 total)