Learn how to set up prerendering in Angular for SEO. Generate static HTML pages, improve Core Web Vitals, and deploy fast, SEO-friendly Angular apps.
๐น What is Prerendering?
Prerendering is the process of generating static HTML pages at build time.
Unlike SSR (server-side rendering, which happens at runtime), prerendering builds your Angular app into ready-to-serve static pages.
๐ This means search engines and users get instant HTML, improving SEO and performance.
๐น SSR vs Prerendering โ Which to Choose?
| Feature | SSR (Angular Universal) | Prerendering |
|---|---|---|
| How it works | Server renders HTML at runtime | HTML generated at build time |
| Best for | Dynamic apps (blogs, e-commerce) | Static apps (landing pages, docs) |
| SEO impact | Excellent | Excellent |
| Performance | Server load increases | Very fast (CDN-ready) |
| Setup complexity | Moderate | Simple |
๐ Rule of Thumb:
- Use SSR for dynamic sites with frequently changing content.
- Use Prerendering for mostly static content.
๐น Step 1: Enable Prerendering in Angular
Angular provides built-in prerendering with Angular Universal.
Install Angular Universal if not already done:
ng add @nguniversal/express-engine
Add prerendering capability:
ng add @nguniversal/builders
๐น Step 2: Configure Angular.json
Add a prerender target inside angular.json:
"architect": {
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"browserTarget": "my-app:build:production",
"serverTarget": "my-app:server:production",
"routes": [
"/",
"/about",
"/contact",
"/blog"
]
}
}
}
๐ Here, the routes array defines which pages will be prerendered.
๐น Step 3: Run Prerender Build
Run this command:
ng run my-app:prerender
๐ This will generate static HTML files for each route inside dist/browser.
๐น Step 4: Verify Prerendered Pages
Open one of the prerendered files:
dist/browser/about/index.html
๐ You should see fully rendered HTML + meta tags (not just <app-root>).
๐น Step 5: Deploy Static Files
Deploy the prerendered output to:
- Netlify / Vercel (great for static sites)
- Firebase Hosting
- AWS S3 + CloudFront
- Any static hosting service
๐ Since prerendering outputs static HTML, no Node.js server is required.
๐น Step 6: Dynamic Content with Prerendering
Prerendering works best for static pages, but what if your site has dynamic routes like /blog/:id?
Options:
- Predefine known routes in
angular.json. - Use a CMS or script to generate a routes.json file.
- Use Scully (Angular static site generator).
๐น Alternative: Using Scully for Prerendering
Scully is a popular static site generator for Angular.
Install Scully:
ng add @scullyio/init
Run prerender:
npm run scully
๐ Scully crawls your Angular app and creates static HTML pages automatically.
๐น SEO Benefits of Prerendering
- โ Fully rendered HTML for crawlers
- โ Instant load โ Better Core Web Vitals
- โ Works even if JS is disabled
- โ Easy deployment to static hosting
- โ Great for blogs, portfolios, documentation
๐น Final Thoughts
Prerendering is a powerful, lightweight alternative to SSR for Angular SEO.
In this blog, you learned:
- What prerendering is and when to use it
- How to set up Angular prerendering step by step
- How to deploy prerendered pages
- Scully as an alternative for static generation
๐ In the next blog, weโll cover Structured Data & Schema Markup in Angular to boost rich snippets and search visibility.
Share this:
- Click to share on Facebook (Opens in new window) Facebook
- Click to share on X (Opens in new window) X
- Click to share on WhatsApp (Opens in new window) WhatsApp
- Click to email a link to a friend (Opens in new window) Email
- Click to share on Pinterest (Opens in new window) Pinterest
- Click to share on LinkedIn (Opens in new window) LinkedIn
- Click to share on Threads (Opens in new window) Threads
- Click to share on Telegram (Opens in new window) Telegram









