In this article, we will consider such questions: “ How to prevent external links from indexing in WordPress? " and " How do I make links in the DoFollow blog comments?". The article is in the category of plugins, so we will do everything with their use.
But first you need to figure out why you need to open and close anything at all.
If the webmaster is not sure of the quality of the resource to which the link leads, then he closes it from indexing using the rel = "nofollow" attribute. The search engines Yandex and Google, seeing this value in the link, will not follow it, and also will not transfer weight.
And now a quite reasonable question: "Why then open links for indexing by search engines, make them Dofollow, if in this case weight will be transferred?"
Everything is quite simple here: those who are engaged in website promotion use Dofollow blog comments as an inexhaustible resource where you can get free external links. And links, as you know, have a certain impact on website promotion, albeit not as strong as before.
Webmasters use this for their own purposes, namely, the automatic filling of the site or blog with content (comments). And it also creates a kind of excitement on the blog, or rather its visibility, since messages are in fact left by spammers. But even so, visitors will have a certain amount of trust in the author after seeing the crazy number of comments on the blog. And it is possible that they will even add the page to bookmarks.
Plugin WP No External Links - close links from indexing
WP No External Links Plugin- an excellent WordPress plugin that allows you not only to automatically add an attribute that blocks links from indexing to all links, but also to make an internal link from an external link using a redirect. This is indicated in the plugin settings as - link "masking". By the way, the same "masking" method is used to hide referral links.
The plugin can be downloaded and installed from the WordPress admin area, or from here: http://wordpress.org/plugins/wp-noexternallinks/
Let's move on to the settings:
Add rel = nofollow- adding a nofollow value for the rel attribute.
Add target = ”_ blank”- highly useful option which adds target = ”_blank” to all xrefs. By enabling this option, all external links will open in a new window. This parameter is important for website optimization.
Add noindex tags- the expediency of using this parameter can be questioned, since rel = "nofollow" is quite enough to search engines Yandex and Google realized that there is no need to follow this link.
Do not mask links using redirects- my personal opinion, this function must be enabled. Search engines are constantly repeating: "The site should be natural!". What could be more natural than a simple external link?
And now the final touch: the plugin described above does not allow opening links in the author's name for indexing when submitting a comment.
This task will help to cope plugin - Do Follow... I will not write anything about its settings, for one simple reason - there are none. The plugin performs all its functions immediately after its activation. You can download everything from the same place - from the WP admin panel.
Greetings to all blog readers! Today I want to show you how to block links from indexing in blog comments. It is not difficult to do this even with minimal knowledge of php. If you have a lot of comments on your blog, then there is a great opportunity not to follow the links and miss a few open links, which is highly undesirable.
Of course, manually following the links in the comments is quite difficult, but installing an extra plugin because of this is also not an option. Therefore, I found, in my opinion, the most optimal solution, in which everything happens automatically, and you do not need to manually track open links.
What exactly is going on? Links are closed with tags
Thus, you can safely not edit every comment by closing links manually or deleting them - all links are automatically closed from indexing by Yandex and Google. How to do it in practice?
First, let's tackle the functions.php file located in your WordPress template directory. You need to insert the following code into it:
Function wp_noindex ($ comment) (return str_replace (" ", "", $ comment);) add_filter (" comment_text "," wp_noindex "); add_filter (" comment_text "," wp_noindex2 ");
The code must be inserted before the closing tag?>. Many do not know this and insert code snippets in the first place in the file, and then wonder why the site stopped working. So, I repeat - just before the closing tag?> At the end of the functions.php file!
Now you need to make some changes to the comment-template.php file. You will not find this file in the theme template folder - it is located in the wp-includes folder. This folder is located in the site directory - where the .htaccess, robots .txt and sitemap .xml files are located. So, in the file comment-template.php you need to find a piece of code:
$ return = "$ author";
And replace this fragment with the next one, which contains the noindex tags that Yandex works with.
$ return = "
Now the work can be considered complete - your comments are protected from open links, and do not pose any threat to the blog. Links will be closed from indexing from the main search engines - Yandex and Google. See you in the following publications.
In one of my previous articles, I talked about blocking links from indexing using JavaScript. Today, I want to show you how to close a commentator's link from indexing in WordPress. In the article, I will give working examples of the code of a function that works on the scripts we discussed earlier to hide links from robots.
To begin with, you definitely need to read my article and insert the javascript you like into the "Footer" (footer.php). If you are already using one of the provided scripts, then just read the article further.
How to close comments in WordPress
I will not redescribe why you need to close comments and why you need to do it through JS. All this is well described in the previous article on this topic, as well as chewed and chewed in the comments to it. I'll just provide you with a working code of a function that will hide links that we don't like.
Example code for hiding a link to a commentator's site
As in the previous article, there will be several methods for closing a link. This is due to the fact that we can use 2 types of scripts from the last article, each of which is divided into two options - for HTML4 and HTML5, respectively. And so, let's get started.
We go to " Console»WordPress → Appearance -> Editor.
On the right in the templates we find and click on "Functions.php" In the opened editor, for convenience, we go down to the end of the code and insert the function code up to the line with the code?>, Having previously selected the desired option.
The first way to close the link of the author of the comment
Applies if the corresponding JavaScript from the previous article is used when the script opens the link itself (method 1)
For HTML4
"," href = "), // what we replace array (" "," rel = "), // array ("For HTML5
/ * ================================================ =========================== * Function for closing the commentator's link via JS * Parameter $ link - html-code of the commentator's link * ====== ================================================== ================== * / function avd_comment_author_link ($ link) ($ link = str_replace (// call the replace function in the string array (" "," href = "), // what we replace // array (" "," rel = "), array (" "," data-url = "), // what do we replace $ link with // in the line with the html-code of the link); return $ link; // return a new link after replacement) // connect the filter add_filter (" get_comment_author_link ", "avd_comment_author_link"); / * ========================================= =============================== * /The second way to close the link
It is used if a similar one is inserted. second JavaScript way, when JS replaces text with link code.
For HTML4
/ * ================================================ ========================== * Function for closing the commentator's link via JS * Parameter $ link - html-code of the commentator's link * ====== ================================================== ================== * / function avd_comment_author_link ($ link) ($ link = str_replace (// call the replacement function in the "href =" line, // what we replace "href = "#" class = "mylink" rel = ", // for html4 //" hfre = "#" class = "mylink" data-url = ", // what we replace $ link with // in the line with html- link code); return $ link; // return a new link after replacement) // add filter add_filter ("get_comment_author_link", "avd_comment_author_link"); / * =============================================== ========================== * /For HTML5
/ * ================================================ ========================== * Function for closing the commentator's link via JS * Parameter $ link - html-code of the commentator's link * ====== ================================================== ================== * / function avd_comment_author_link ($ link) ($ link = str_replace (// call the replacement function in the "href =" line, // what we replace // "href =" # "class =" mylink "rel =", // for html4 "hfre =" # "class =" mylink "data-url =", // what we replace $ link with // in the line with html- link code); return $ link; // return a new link after replacement) // add filter add_filter ("get_comment_author_link", "avd_comment_author_link"); / * =============================================== ========================== * /Attention!
- Before installing the function code, check for the link hiding script in footer.php. If you have not installed it yet, do it, guided by the corresponding article on my blog.
- Choose the function you want carefully. It must correspond to the used script, which closes links from indexing.
Video lesson of closing the author's link from indexing.
PS. If my article is useful to you, the best gratitude from you will be a subscription to our newsletter. If you have any problems or questions - feel free to write to us. We will always help you to cope with any difficulties.
On January 14, 2015 we released the Hide Links plugin, with which you can easily hide the link in the text of the article without manually adding codes and scripts. Also, this plugin automatically hides commentator links.
Hello friends, today I will tell you a simple way to get rid of the indexing of the links of the authors of comments, and at the same time leave the links outwardly in place. The solution was found by me on the Internet, it has been tested and works! =)
Once my blog was, this experiment was completed by me due to the huge number of open links in the comments, which negatively affected not only the high rate of "link spam" to my site, but also a decrease in trust from search engines. And now the nofollow tag doesn't help much. As far as I understand, the page weight smoothly flows to the pages of sites whose authors left comments in the article.
To date, I have solved this problem using the plugin WP No External Links, which simply replaced the link of the author of the comment with a link of the form "site / goto / link" as shown in the picture above.
After starting to use this plugin, the spamming of links really dropped significantly, which of course pleased me.
But at the same time, the number of comments dropped significantly. After all, many, one way or another, comment on sites because of links to them, and seeing in the comments the structure of the authors' links of the form "site / goto / link" did not dare to leave comments.
By the way, in the html-code of the page, this construction looks like this:
Olga Andreeva
In the end, I searched and found the following solution for this matter:
How to close commenter links from indexing without plugins?
The first thing I did was deactivate the plugin and return all commenter links to their normal state.
Olga Andreeva
After this step, I have to make changes to 2 files and the solution will be implemented!
1. I make changes to the file comment-template.php which is located in the folder wp-includes
I do not forget to make a copy of the file before editing, just in case, and look for the line in it:
"$ author";And I change this line to this:
"$ author";
2. I make changes to the file footer.php your topic, literally before the closing tag