Loading external "pages" via AJAX. Will Google crawl?

2

I'm doing a project whose pages are loaded into a main container .

All link is an anchor but what is after the hash is really a path. My JavaScript is scheduled to detect hash swap events, so it picks up the path by subtracting the hash and loads the contents of the file into the main container .

Look at the script , it's very simple!

    (function ($) {

        function hashNavigate() {

            var url = window.location.href;
            var hash = url.substring(url.indexOf('#'));
                hash = hash.replace("#", "");

            if( /#/.test(url) ) { // se houver Hash (se nao for pagina inicial)

                if(!$("#mainRow").html().length) { // se mainRow estiver vazia, apenas carrega o conteúdo

                    $("#mainRow").load(hash);
                } else {

                    $("#mainRow").html("").load(hash); // senão, apaga o conteúdo e carrega o novo em seguida
                }
            }       
        }

        hashNavigate() // executa a primeira vez 

        $(window).on("hashchange", hashNavigate) // armazena no evento

    })(jQuery);

In this way will my site be indexed?

obs : Every external document loaded in the main container does not have a complete HTML structure, just what should be loaded inside it and a tag > script.

    
asked by anonymous 02.08.2015 / 03:47

1 answer

3

Even if Google eventually can execute code in JavaScript, do not tell it to be perfect and reproduce exactly what you expect.

In fact, Google's current documentation clearly tells you to prepare content which depends on AJAX to be read also without the use of JS. This is good for users who do not have browser-enabled JS as for the crawler indexing. If they say this, will you trust anything extra undocumented that they might be offering?

Their recommendation (and I say it should not be just because of them) is to make pages that do not depend on JS and then put what they need to only improve the usability of the page. This is known as progressive enhancement .

What they do is have accessible content that does not depend on JS and even links for pages that will be assembled with AJAX are also available in the traditional way.

Other than that, there's only one way to make sure you know if your specific case will work out, and see if it indexes as you expect.

Maybe someone with more knowledge about this comes here and makes sure it indexes. I would not risk saying that. I may be wrong and I may not have understood the description of the question (even because I do not have all details on using this code) but I think the code is too complex (what it does and not its writing) for Google to run correctly .

See also the AJAX Google Guide .

    
02.08.2015 / 04:14