We have an angular SPA using node, nginx, and prerender.io. Our home page is set as a unique url (i.e. www.foo.com/bar) and in our routing, this home page captures the default redirect of all root-relative urls not specifically routed otherwise.
Our problem is this: the root url www.foo.com or www.foo.com/ comes back with a blank page scrape for google and Facebook. Our index is an ng-include basic template that all pages are inserted inside of, so it makes sense that our root url comes back without any real html body content. Main html in index:
<div class="st-content">
<div ng-view="" class="main-content" id="mainView"></div>
<div ng-include="'/views/footer.html'"></div>
</div>
Additionally, we have tried other solutions without positive results:
Note: in writing this question it occurred to me to change the home routing to ‘/':
.when('/', {
templateUrl: '/views/foo-bar.html',
title: ‘Foo Bar',
pageDescription: ‘Lorem Ipsum Foo Bar'
})
.
.
.
.otherwise({
redirectTo: '/'
});
If changed to this will the home scrape still show as blank? Isn’t this basically the same js redirect problem, but with less characters?
You need to set the window.prerenderReady
variable. Thus, put this in your route controller:
window.prerenderReady = false;
... and this in your controller's success callback function:
window.prerenderReady = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With