1

I am trying to use PhantomJS and angular-seo (https://github.com/steeve/angular-seo) to make my app crawlable.

As I am not using hashbangs, I've added the following meta tag to my app's header:

<meta name="fragment" content="!" />

In my main controller, I trigger $scope.htmlReady when the content is fully loaded:

  $scope.$on('$viewContentLoaded', function() {
    $scope.htmlReady();
  });

I have loaded the seo module properly and while my server's app listens on port 4000 (I use an express server), I launch phantomJS on port 4040 with the following command:

phantomjs --disk-cache=no ./bin/angular-seo-server.js 4040 http://127.0.0.1:4000

If I check how things are working for the homepage with a simple curl 'http://127.0.0.1:4040/?_escaped_fragment_=' I get the correct HTML rendered properly.

But if I try a different route like http://127.0.0.1:4040/test?_escaped_fragment_= I only get <html><head></head><body></body></html> while http://127.0.0.1:4000/test works fine.

How can I make sure all my pages are indexed and not only my homepage?

Spearfisher
  • 8,445
  • 19
  • 70
  • 124
  • It seems you need one instance of angular-seo running for each base page, you would need `phantomjs --disk-cache=no ./bin/angular-seo-server.js 4040 http://127.0.0.1:4000/test` for your example url to work I think. – Daniel Edholm Ignat Dec 02 '14 at 10:47
  • 1
    Thanks, this works but how can it be implemented for pages like http://127.0.0.1:4000/product/:product_id ? If I want to reference all my product I cannot run as many instances as I have products... – Spearfisher Dec 02 '14 at 10:52
  • Maybe you could achieve the desired effect by putting the application in "Hashbang in HTML5 mode"? That way all of your pages would be reachable on the same base url for phantomJs. http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashbang-mode-link-rewriting – Daniel Edholm Ignat Dec 02 '14 at 12:43
  • 1
    thanks for the help, I made a quick change to the angular-seo-server file to accept the pushState method and it now works like a charm – Spearfisher Dec 02 '14 at 14:46

0 Answers0