Redoc: Server-side pre-rendering for SEO

Created on 4 Jun 2018  路  4Comments  路  Source: Redocly/redoc

This might be just a question/docs tweak.

(Can't tell if the feature I need exists or not...)

I found these promising bits in Readme.md:

  • Features: "redoc-cli with ability to bundle your docs into zero-dependency HTML file"
  • Roadmap: "docs pre-rendering (performance and SEO)" crossed out

And:

But...

  • https://github.com/Rebilly/ReDoc/issues/124 was closed as out of scope.
  • redoc-cli says "starts the server" but not much else. I don't want to keep another web server continuously running, listening on the network. There are security implications to this. I just want to generate static HTML when CI runs.

ReDoc's client-side JavaScript rendered docs work well. We're using that for most clients.

But like #124, sometimes server-side static HTML is needed for PDF engines and SEO. If the client is a search engine/print app that doesn't run JavaScript (or not extensively enough) and therefore _cannot search index or print JavaScript-rendered docs_, then I need to return static HTML instead.

Does ReDoc CLI do this?

question

Most helpful comment

ok, so "Zero-dependency HTML file" - server-side rendered ReDoc with embedded ReDoc.

So all the initial HTML + CSS are in the HTML and can be rendered by the browser immediately. But it is not interactive. That's why bundle contains ReDoc embedded js which hydrates the view and makes it interactive.

You can use ReDoc from the CDN instead of embedding it into the page by passing --cdn option to bundle command.

It works exactly same as any Server Side rendered React application so look there for more detailed information.

Practically, it means you can deploy resulting HTML to any static hosting or just send it via email and user will be able to just double-click your file to see it.

Hope this answer is more useful!

All 4 comments

redoc-cli says "starts the server" but not much else

use redoc-cli's bundle command instead of serve which

bundles spec and ReDoc into zero-dependency HTML file

@RomanGotsiy Sorry, but that doesn't yield a yes/no answer... That's why I had to ask.

"Zero-dependency HTML file" is a sexy sound bite, but ambiguous.

For example, it _could_ mean one HTML file with embedded ReDoc. That would _not_ be what I need. Or it could mean static HTML, no JavaScript. Or no node.js dependencies. I can't tell. I need something less marketing-ish and more tech doc-ish about the feature's intended behaviour.

So... "Yes, bundles will be static HTML+CSS only (no JS)"? Or "No, bundles will still require a JS engine to render the page"?

ok, so "Zero-dependency HTML file" - server-side rendered ReDoc with embedded ReDoc.

So all the initial HTML + CSS are in the HTML and can be rendered by the browser immediately. But it is not interactive. That's why bundle contains ReDoc embedded js which hydrates the view and makes it interactive.

You can use ReDoc from the CDN instead of embedding it into the page by passing --cdn option to bundle command.

It works exactly same as any Server Side rendered React application so look there for more detailed information.

Practically, it means you can deploy resulting HTML to any static hosting or just send it via email and user will be able to just double-click your file to see it.

Hope this answer is more useful!

Perfect. That's what I needed to know. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shreyas-agnihotri picture shreyas-agnihotri  路  3Comments

dwilding picture dwilding  路  4Comments

zmes50416 picture zmes50416  路  3Comments

bmarwell picture bmarwell  路  3Comments

RamakrishnaChilaka picture RamakrishnaChilaka  路  3Comments