R
R
Ranger Nicholas2018-07-19 07:35:08
JavaScript
Ranger Nicholas, 2018-07-19 07:35:08

Closing from indexing by means of ajax jQuery. How does it work?

I'm trying to close some blocks on the site from indexing by search engines. I do it like this:

  1. I connect jquery (tried in head and in the code itself)
    <script src="https://yastatic.net/jquery/3.1.1/jquery.min.js"></script>

    Immediately a problem arises. The layout breaks. There is a suspicion that this is due to the fact that another version is already connected somewhere. Could this be the reason or is the problem something else?
  2. Then I set the block that needs to be closed with an id (id) and load it with this construction
    <div id="noindex"></div>
    <script>
    $(function() {
        $('#noindex').load('/')
    })
    </script>

    Where "#noindex" is the block selector and "/" is the page address


The question itself is, where can you check whether it is really closed from indexing and this block is not visible to search engines?
And what to do so that the layout does not float after connecting jQuery?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ranger Nicholas, 2018-07-20
@rangernicholas

Figured it out myself. Maybe someone will be useful.
I will describe the connection step by step.

  1. We create a file on the server with the code of the block to be hidden and the extension .php for example noindex.php
  2. We connect it in head with the construction
    <script type="text/javascript">
    $(document).ready(function() {
    $("#noindex").load("/noindex.php");
    });
    </script>

    Where:
    “#noindex” is a block selector that the search engine should not see
    “/noindex.php” is the path to the file where our block code is stored
  3. The connection is successful if there is an empty block in the code <div id="noindex"></div>, but the elements themselves are present and displayed on the site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question