From c88aa1b639684a371f7dd3ac6f38f9cfa3c9ac66 Mon Sep 17 00:00:00 2001 From: Corentin BARAULT <74433435+Kirbeerus@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:16:57 +0100 Subject: [PATCH] Add prerender.io to Static doc (#491) ## Describe your PR Some client may want to prerender there SPA application to have better SEO. One of the way to do it is by using prerender.io Added a part in the documentation to talk about how to do it on Clever Cloud. You can check if prerender.io work correctly on your app by using this guide. https://docs.prerender.io/docs/how-to-test-your-site-after-you-have-successfully-validated-your-prerender-integration ## Checklist - [x] My PR is related to an opened issue : # - [x] I've read the [contributing guidelines](/CleverCloud/documentation/blob/main/CONTRIBUTING.md) ## Reviewers _Who should review these changes?_ @CleverCloud/reviewers --------- Co-authored-by: Julia March <101819212+juliamrch@users.noreply.github.com> Co-authored-by: Pierre L. / Peyo <166715564+PLhuillery@users.noreply.github.com> --- content/doc/applications/static/_index.md | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/content/doc/applications/static/_index.md b/content/doc/applications/static/_index.md index 51f9c596e..186b2a064 100644 --- a/content/doc/applications/static/_index.md +++ b/content/doc/applications/static/_index.md @@ -66,6 +66,36 @@ RewriteRule ^ - [L] RewriteRule ^ /index.html ``` +## Prerendering with Prerender.io + +When you use a SPA framework, you are using Client side rendering. +One of the problem with this method is a poor SEO as search engine crawlers have more difficulty reading the content of this type of application. +To minimize this issue, prerendering can be a solution. + +If you want to Prerender your application on Clever Cloud, one solution is to use [Prerender.io](https://prerender.io/). +To use it with our static applications, you need a `.htaccess` file like this at the root of your project: + +```ApacheConf + + RequestHeader set X-Prerender-Token "" + RequestHeader set X-Prerender-Version "prerender-apache@2.0.0" + + + + RewriteEngine On + + + RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|redditbot|applebot|flipboard|tumblr|bitlybot|skypeuripreview|nuzzel|discordbot|google\ page\ speed|qwantify|bitrix\ link\ preview|xing-contenttabreceiver|google-inspectiontool|chrome-lighthouse|telegrambot [NC,OR] + RewriteCond %{QUERY_STRING} _escaped_fragment_ + RewriteCond %{REQUEST_URI} ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff|\.svg)) + + RewriteRule ^(index\.html|index\.php)?(.*) http://service.prerender.io/%{REQUEST_SCHEME}://%{HTTP_HOST}$2 [P,END] + + +``` +You can find your `PRERENDER_TOKEN` on your [Prerender.io account](https://prerender.io/). + +You can verify your configuration work using [this guide](https://docs.prerender.io/docs/how-to-test-your-site-after-you-have-successfully-validated-your-prerender-integration). ## Apache Configuration with `CC_WEBROOT` If you set the `CC_WEBROOT = /` environment variable, make sure you put your `.htaccess` file at the root of your `/`. This is where Apache will look for directives when you deploy an application in a Static runtime.