0

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.

developer10
  • 1,450
  • 2
  • 15
  • 31
  • `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: http://stackoverflow.com/questions/6193858/pushstate-and-seo – Sergiu Paraschiv Jun 12 '14 at 08:58
  • @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. – developer10 Jun 12 '14 at 09:09
  • 1
    The point is any AngularJS directive modifies the DOM throught JavaScript. Googlebot will understand _some_ 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` manipulation *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. – Sergiu Paraschiv Jun 12 '14 at 09:14
  • @SergiuParaschiv So you're saying that along with using `pushState` for changing my URLs I need to have correct `href` (rather than `ng-href`) set in order for Google to understand it? – developer10 Jun 12 '14 at 09:53
  • 1
    Yes. It's all explained in the first question I linked to. – Sergiu Paraschiv Jun 12 '14 at 09:56
  • @SergiuParaschiv Sorry if I bother you - by reading that question, I got an impression that it should be done just like I would do by going with pure PHP: make links lead to appropriate pages and actually open/visit them. But what actually happens "under the hood" is that the content is being served by AngularJS, not PHP. Correct? This way Google isn't aware at all, nor does it care, who serves the content. – developer10 Jun 12 '14 at 10:14
  • Yes. Basically you need to respond to crawlers with proper HTML, headings and all. Make sure you read Google's guidelines here: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started – Sergiu Paraschiv Jun 12 '14 at 10:23

0 Answers0