Aplicación que no es de una sola página: use pushState para cambiar la URL en la barra de direcciones al hacer clic

So my app is not SPA. I use Angular in certain spots and sometimes on a whole page but what I see in my address bar is my server page (PHP).

Now, there is a page where I'd like to have my categories displayed as clickable links/buttons and to display listings of clicked categories.

While this isn't too difficult to implement, I'm worried about the SEO aspect thereof. I came across pushState thing which should "seemingly" change the url on button click. You can see it in action here html5.gingerhost.com

You can verify that the page is not changed by playing Youtube video on the right prior to clicking any buttons.

Now, I wonder if there is any chance I can utilize this in my ng-click method. The indented behavior is to have the URL in the address bar to keep my server page in place, and just add my category seo name after it.

preguntado el 12 de junio de 14 a las 09:06

ng-click is a directive that attaches a on('click') event handler on your link. You need to set href to something googlebot can read: stackoverflow.com/questions/6193858/pushstate-and-seo -

@SergiuParaschiv I just tried adding ng-href to a link and seeing if it'd take me anywhere. It didn't. Actually nothing happened. I'm afraid I'm not following you completely. -

The point is any AngularJS directive modifies the DOM throught JavaScript. Googlebot will understand algo JavaScript you throw at it, but what AngularJS directives do is too complicated and basically ignored. Googlebot on the other hand does understand basic pushState manipulación if your hyperlinks (a tags) have correct href attributes (that have not been added through JS DOM manipulation) pointing to the actual HTML fragment to be loaded asynchronously. So ng-href, ui-sref, ng-click or any other AngularJS directives won't work. -

@SergiuParaschiv So you're saying that along with using pushState for changing my URLs I need to have correct href (más bien que ng-href) set in order for Google to understand it? -

Yes. It's all explained in the first question I linked to. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.