Home Forums WoodMart support forum outgoing internal links contain nofollow attribute in woodmart

outgoing internal links contain nofollow attribute in woodmart

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #686046

    Carlo
    Participant

    Hi,
    have you a suggestion for this problem ?? tks

    #686238

    Hung Pham
    Participant

    Hi Carlo,

    Thanks for reaching to us.

    Please provide me with mentioned url so I can take a look.

    Regards,
    Hung PD

    #686435

    Carlo
    Participant

    Hello, you see the attached information. tks

    #686969

    Hung Pham
    Participant

    Hi Carlo,

    Thanks for your patience.

    Can you please let me know which specific parts you want to remove nofollow attr?

    Regards,
    Hung PD

    #687231

    Carlo
    Participant

    HI,
    internal links no needs nofollow attr, if you show me as fix it, i will do it. more 500 links has this problem.
    Needs a fast solution. Tks

    #687461

    Hung Pham
    Participant

    Hi Carlo,

    Thanks for your patience.

    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 6 posts - 1 through 6 (of 6 total)