Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO and google-ability of dynamic generation #1608

Closed
erikvanzijst opened this issue Sep 16, 2015 · 6 comments
Closed

SEO and google-ability of dynamic generation #1608

erikvanzijst opened this issue Sep 16, 2015 · 6 comments

Comments

@erikvanzijst
Copy link

As we're evaluating swagger-ui for our public-facing API documentation, I wonder if its dynamic approach of downloading swagger.json and constructing the page at runtime will prevent the documentation from getting crawled and becoming searchable.

According to Google:

To make the crawler see what a user sees, the server needs to give a crawler an HTML snapshot, the result of executing the JavaScript on your page.

https://developers.google.com/webmasters/ajax-crawling/docs/learn-more

Is there anything I'm overlooking here, or could this really be an issue?

@fehguy
Copy link
Contributor

fehguy commented Sep 17, 2015

While google is getting better at rendering & indexing dynamic content, I'm not sure if swagger-ui is indexable. I do seem to find quite a few swagger-ui instances via google search, but haven't spent a bunch of time figuring out what is being indexed on them.

@erikvanzijst
Copy link
Author

Google is getting better, but it does not currently run javascript to the point of making ajax calls, as indicated by their docs.

We're evaluating swagger-ui as a candidate for Bitbucket's future API documentation. However, searchability of the documentation is key to making our API accessible.

To verify, I got Google to index our swagger site, which confirmed that it merely looks at the index.html and never pulls down the swagger.json:

swagger_search

Are there plans to make swagger-ui indexable, or providing a way to generate static HTML offline?

@dolmen
Copy link
Contributor

dolmen commented Oct 1, 2015

Related: swagger-api/swagger-editor#664

@erikvanzijst
Copy link
Author

So after learning about the spec attribute to SwaggerUi(), I can confirm that using that over the AJAX-based URL approach fixes the crawling problem.

I embedded the swagger json data in a .js file:

$ ( echo -n 'var spec = ' && curl http://url.to/swagger.json ) > swagger.js

then loaded that synchronously in the page's head:

<script src='/swagger.js' type='text/javascript'></script>

fed it to SwaggerUi():

window.swaggerUi = new SwaggerUi({
  url: null,
  spec: spec,
  ...

And Google now indexes correctly:

swagger-seo

@webron
Copy link
Contributor

webron commented Oct 13, 2015

@erikvanzijst - thanks for sharing the details of your research. I'm sure it would prove helpful to other users.

@imZack
Copy link

imZack commented Apr 21, 2016

wow, very useful hack. it's better to add in docs.
thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants