AJAX & SEO: Le migliori soluzioni

Preview:

DESCRIPTION

Fin dagli inizi, AJAX ha creato non poche problematiche ai SEO. L'intervento illustrerà le migliori soluzioni ideate in questi anni per non avere alcune tipo di problema SEO con AJAX.

Citation preview

Giorgio Taverniti – Founder GT Idea - #convegnogt

Andrea CardinaleFounder Web and Tech

AJAX & SEOLE MIGLIORI SOLUZIONI ATTUALI!

@CardinaleAndrea+AndreaCardinale

Andrea Cardinale

www.andrea-cardinale.it

@CardinaleAndrea

+AndreaCardinale

www.webandtech.it

Andrea Cardinale – Founder Web and Tech - #convegnogt

Un po' di storia

Asynchronous JavaScript and XML

Venne denominata Ajax

per la prima volta

nel 2005 da Jesse Garrett

in un articolo del suo blog

Venne denominata Ajax

per la prima volta

nel 2005 da Jesse Garrett

in un articolo del suo blog

Andrea Cardinale – Founder Web and Tech - #convegnogt

Un po' di preistoria

Andrea Cardinale – Founder Web and Tech - #convegnogt

Cosa consiste

Scambio di dati in backgroundfra browser ed il server

RichiestaAJAX

PAGINA WEBPAGINA WEBSERVERSERVER

Aggiornamentocontenuto

Andrea Cardinale – Founder Web and Tech - #convegnogt

Perché utilizzarlo ?

Asincronismo

Velocità d'interazione

Migliora l'esperienza utente

Andrea Cardinale – Founder Web and Tech - #convegnogt

Perché ne parlo ?

Andrea Cardinale – Founder Web and Tech - #convegnogt

Uno sguardo al web

Andrea Cardinale – Founder Web and Tech - #convegnogt

Ajax vs SEO (Uno sguardo al web)

Andrea Cardinale – Founder Web and Tech - #convegnogt

Terzo incomodo (Uno sguardo al web)

Andrea Cardinale – Founder Web and Tech - #convegnogt

Assassin's Ajax IV (Uno sguardo al web)

Andrea Cardinale – Founder Web and Tech - #convegnogt

Indicizzazione (Uno sguardo al web)

“ Ajax può rendere difficoltosal’indicizzazione del sito

da parte dei motori di ricerca ”

Andrea Cardinale – Founder Web and Tech - #convegnogt

Accessibilità (Uno sguardo al web)

“ Ajax può ostacolare l’accessibilitàdei contenuti e del sito ”

Andrea Cardinale – Founder Web and Tech - #convegnogt

Disorientamento (Uno sguardo al web)

“ Ajax può disorientare l’utente:non interagisce con i bottoniavanti e indietro del browser ”

Andrea Cardinale – Founder Web and Tech - #convegnogt

Le vostre esperienze?

Andrea Cardinale – Founder Web and Tech - #convegnogt

Andrea Cardinale – Founder Web and Tech - #convegnogt

Un mio dogma

Andrea Cardinale – Founder Web and Tech - #convegnogt

"Cominciate col fare ciò che è necessario, poi ciò che è possibile.

E all'improvviso vi sorprenderetea fare l'impossibile"

San Francesco d'Assisi

"Cominciate col fare ciò che è necessario, poi ciò che è possibile.

E all'improvviso vi sorprenderetea fare l'impossibile"

San Francesco d'Assisi

Il problema

Andrea Cardinale – Founder Web and Tech - #convegnogt

Perché nasce?

La colpa

Sviluppatore smanettone

Andrea Cardinale – Founder Web and Tech - #convegnogt

Il problema

<a href=”/buon-vecchio-url/”>Label</a>

<a href=”javascript:SuperFigata();”>Label</a>

Andrea Cardinale – Founder Web and Tech - #convegnogt

Il problema

<a href=”/buon-vecchio-url/”>Label</a>

<a href=”#SuperFigata” onclick=”javascript:SuperFigata();”>Label</a>

Andrea Cardinale – Founder Web and Tech - #convegnogt

Risultato

Il Link non contiene più una URL

I tasti (avanti e indietro) del browser non funzionanocome dovrebbero

Senza javascript non funziona una cippa

Il Crawler... inutile dirlo!

Andrea Cardinale – Founder Web and Tech - #convegnogt

Houston,abbiamo

un problema!

Andrea Cardinale – Founder Web and Tech - #convegnogt

Il concetto

Tecnologie come AJAX

devono rappresentare una miglioria,

non sostituire o eliminare funzioni basilari

Tecnologie come AJAX

devono rappresentare una miglioria,

non sostituire o eliminare funzioni basilari

Andrea Cardinale – Founder Web and Tech - #convegnogt

Soluzioni

Andrea Cardinale – Founder Web and Tech - #convegnogt

Google

Making AJAX Applications Crawlable

https://developers.google.com/webmasters/ajax-crawling/

Andrea Cardinale – Founder Web and Tech - #convegnogt

GoogleAnziché utilizzare #

Si utilizza #!Indichiamo che utilizziamo l' AJAX crawling scheme

Il crawler richiede al server il contenuto del seguente URL

www.example.com/ajax.html#key=value

www.example.com/ajax.html#!key=value

www.example.com/ajax.html?_escaped_fragment_=key=value

Andrea Cardinale – Founder Web and Tech - #convegnogt

Google

Server side

Esempio PHP:

if(isset($_GET['_escaped_fragment_'])){

$escaped = explode("=", $_GET['_escaped_fragment_']);

if(isset($escaped[1]) && in_array($escaped[1], $files)){

include ("./views/".$escaped[1].".php");

}

}

Esempio PHP:

if(isset($_GET['_escaped_fragment_'])){

$escaped = explode("=", $_GET['_escaped_fragment_']);

if(isset($escaped[1]) && in_array($escaped[1], $files)){

include ("./views/".$escaped[1].".php");

}

}

Andrea Cardinale – Founder Web and Tech - #convegnogt

Google

Making AJAX Applications Crawlable

Andrea Cardinale – Founder Web and Tech - #convegnogt

Bing

Making AJAX Applications Crawlable

https://developers.google.com/webmasters/ajax-crawling/

Andrea Cardinale – Founder Web and Tech - #convegnogt

Bing

Making AJAX Applications Crawlable

https://developers.google.com/webmasters/ajax-crawling/

Andrea Cardinale – Founder Web and Tech - #convegnogt

Hijax

Progressive Enhancement with Ajax

Andrea Cardinale – Founder Web and Tech - #convegnogt

Hijax

<a href=”/buon-vecchio-url/”>Label</a>

<a href=”javascript:SuperFigata();”>Label</a>

<a href=”/buon-vecchio-url/” class=”ajax”>Label</a>

Andrea Cardinale – Founder Web and Tech - #convegnogt

Hijax

Andrea Cardinale – Founder Web and Tech - #convegnogt

Client side

Intercetto il click sul link con class=”ajax”

Annullo la richiesta della URL

Effettuo una chiamata ajax al server

Ricevo il contenuto dal server

Effettuo la modifica

Hijax

Andrea Cardinale – Founder Web and Tech - #convegnogt

Server side

Ricevo la richiesta

Identifico la richiesta come Ajax

Render del contenuto senza layout

Hijax

Andrea Cardinale – Founder Web and Tech - #convegnogt

Client side - Esempio

$( document ).ready(function() {$("a.ajax").each(function() {

var a_url = $(this).attr('href');$(this).click(function(e) {

e.preventDefault();$.ajax({

url: a_url, data: 'ajax=1', type: 'GET',}).success(function(data) {

$('#content').html(data);});

});});

});

Hijax

Andrea Cardinale – Founder Web and Tech - #convegnogt

Server side - Esempio

if(isset($_GET['ajax'])) {//includo solo la vistarequire_once('views/'.$view.'.php');

} else {//includo tutto il layoutrequire_once('layouts/'.$layout.'.php');

}

Rimane un problema

Andrea Cardinale – Founder Web and Tech - #convegnogt

User Experience compromessa

URL#

Andrea Cardinale – Founder Web and Tech - #convegnogt

Client side

Modifico l'URL con #URL ( class=”ajax” )

Intercetto il cambio dell'hash

Effettuo una chiamata ajax al server all'URL chesi trova dopo #

Ricevo il contenuto dal server

Effettuo la modifica

URL#

Andrea Cardinale – Founder Web and Tech - #convegnogt

Client side - Esempio

$( document ).ready(function() {$("a.ajax").each(function() {

var a_url = $(this).attr('href');$(this).attr('href', '#'+a_url);

});});

$(window).hashchange( function(){var a_url = window.location.hash.substr(1);$.ajax({

url: a_url, data: 'ajax=1', type: 'GET',}).success(function(data) {

$('#content').html(data);});

});

Pjax

Andrea Cardinale – Founder Web and Tech - #convegnogt

pushState + Ajax

history.pushState(data, "Titolo", "/url-new/");

pushStatepushState

Pjax

Andrea Cardinale – Founder Web and Tech - #convegnogt

Client side - Esempio

$( document ).ready(function() {$("a.ajax").each(function() {

var a_url = $(this).attr('href');$(this).click(function(e) {

e.preventDefault();$.ajax({

url: a_url, data: 'ajax=1', type: 'GET',}).success(function(data) {

history.pushState('', $(this).attr('title'), a_url);$('#content').html(data);

});});

});});

Pjax

http://caniuse.com/#search=pushstate

Andrea Cardinale – Founder Web and Tech - #convegnogt

Andrea Cardinale – Founder Web and Tech - #convegnogt

Andrea Cardinale – Founder Web and Tech - #convegnogt

Parallax scrolling

Andrea Cardinale – Founder Web and Tech - #convegnogt

(Uno sguardo al web)

“SEO e problemi di ottimizzazione:il parallax riduce il numero di pagine necessarie

per fornire informazioni, ciò non consente quindi diottimizzare il sito con un’ampia varietà di keywords.”

Parallax scrolling

Andrea Cardinale – Founder Web and Tech - #convegnogt

(Uno sguardo al web)

Andrea Cardinale – Founder Web and Tech - #convegnogt

Arrendersi?...Arrendersi?...

Andrea Cardinale – Founder Web and Tech - #convegnogt

… o reagire?… o reagire?

Parallax scrolling

Andrea Cardinale – Founder Web and Tech - #convegnogt

MELA PERA KIWIHOME

FRUTTA

MELA

PERA

KIWI

SCROLLING

11

22

33

44

Parallax scrolling

Andrea Cardinale – Founder Web and Tech - #convegnogt

MELA PERA KIWIHOME

FRUTTA

Base HTML(senza javascript)

/ /mela/ /pera/ /kiwi/

URLs menu

Parallax scrolling

Andrea Cardinale – Founder Web and Tech - #convegnogt

MELA PERA KIWIHOME

FRUTTA

MELA

PERA

KIWI

… Caricamento tramite Ajax ...

Con javascript

Esempi

Andrea Cardinale – Founder Web and Tech - #convegnogt

www.andrea-cardinale.it/convegnogt2013/

Links

Andrea Cardinale – Founder Web and Tech - #convegnogt

Making AJAX Applications Crawlablehttps://developers.google.com/webmasters/ajax-crawling/

jQuery hashchange eventhttp://benalman.com/projects/jquery-hashchange-plugin/

jquery-pjaxhttps://github.com/defunkt/jquery-pjax/

Ajax SEOhttps://github.com/laukstein/ajax-seo

Giorgio Taverniti – Founder GT Idea - #convegnogt

Andrea CardinaleFounder Web and Tech

AJAX & SEOLE MIGLIORI SOLUZIONI ATTUALI!

@CardinaleAndrea+AndreaCardinale

Recommended