Can I get AngularJS to use different controllers for Facebook OpenGraph scraper?

Viewed 220

I have an AngularJS application that is served up using http-server

I want my the meta-tags (og:title, og:description, og:image) to be populated dynamically for Facebook and other scrapers (like Slack) to post rich-links on social media sites. However, it is tricky because those scrapers do their scraping of the original HTML page before angular dynamically inserts the proper values. So the scrapers see the placeholder values.

One solution to this problem is described here. Basically: feed the scraper-bots static HTML with desired og fields already populated. I would like to do that. But unlike that author, I'm not using apache. In http-server there is no .htaccess file that I'm aware of.m

I use UI-Router and $state-provider to handle the URLs provided to my application like this:

  $stateProvider.state('splash',
      {
          url: '/',
          templateUrl: 'html/splash.html',
          controller: 'SplashCtrl',
          data: {
              meta: {
                'title': 'My Title',
                'description': 'My Description'
              }
          }
      }
  );

Is there some way I can create a state such that scraper-bots will be sent to a different controller than normal human users using a web-browser? How?

1 Answers
Related