ajax-seo
ajax-seo copied to clipboard
Getting response: <html><head></head><body></body></html>
Hello, Your solution looks damn good to solve SEO problem. I am trying to implement it to serve the angular app but getting the following response
<html><head></head><body></body></html>
The seo.js
file is placed along with the index.html
. The following curl command is used to get the html content.
curl localhost:8888/?_escaped_fragment_=/index.html
I have edited the index.html
file for the meta tag
. Did everything as you explained but not getting the actual response.
I think you are trying to visit:
curl localhost:8888/index.html?_escaped_fragment_=
make sure your angular app can handle url like this:
localhost:8888/index.html#!
see this for the explanations of escaped_fragment: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started#2-set-up-your-server-to-handle-requests-for-urls-that-contain-escaped_fragment
@liuwenchao I tried running curl localhost:8888/index.html?_escaped_fragment_=
but still its output is blank and the curl
gets hanged after running this. How to debug this?
I tried replacing the index.html with a plain html content with the required meta tag but still facing the same issue.
One more thing I would like to add on about my app configuration is that in the agular app, the HTML5 mode is enabled.
You need to add code in your angular app to be "AJAX crawlable.", which means when your visit urls like
localhost:8888/ajax.html#!key=value
in the browser or using curl, you will see fully rendered html.
check out the google doc again, you missed the first part of the guide.
I updated readme file of this repo, you inspired me ;)
@liuwenchao I understood your point. But as mentioned here one may use either hashbang
url way or html5
way to make the website ajax crawlable.
If you wish not to use hashbang URLs but still inform Google that your website contains AJAX content then include this meta tag within the head tag of the file being accessed at the given URL.
<meta name="fragment" content="!" />
And as I stated in my previous comment, I am using HTML5
mode, hence it should work.
@liuwenchao The phantomjs server is running fine now and also serving the index page with the following command curl mydomain.com/?_escaped_fragment_=/
But when am trying to access other pages like curl mydomain.com/?_escaped_fragment_=/id/1
, it still serves the index
page only. Any suggestions for this?
not sure how you fixed the index page.
for the new question: curl mydomain.com/?_escaped_fragment_=/id/1
, what's your expectation for the response?
@liuwenchao My expectation is to get the page for /id/1
but getting the index page only
meta tag only works for pages without hash fragments
, for /id/1
you have to use hashbang mode, and add code in your app to handle hashbang url.
@liuwenchao Angular by default supports hashbang urls
and I have tested it out too by hitting the url with hashbang
. HTML5 mode is also enable in the app and the link I provided above states that either hashbang url or HTML5 mode has to be their to get things work.
I never tried to use both meta tag and hashbang in one ajax page, meta tag may override hashbang. You can try to remove the meta tag to see if hashbang is taking control of it.
By the way, I shifted to prerender
only as this solution was not working out for me. Most probably am doing something wrong while setting up your solution. May be you should put some more things in the documentation (detailed documentation) like prerender
guys have done. What I think is, the documentation should be like there should not be any assumption at the users end. Everything should be mentioned in a detailed way (without assuming anything for a novice user). Thanx a lot for your help :)