Skip to content

Angular SEO: server-side rendering for crawlers and AI

Angular SEO depends on what your server sends. How to check raw HTML, set up @angular/ssr or prerendering, set per-route metadata and return real 404s.

By Crawlito · 8 min read

In short

  • Angular's documentation says client-side rendering is the default behaviour and that it can hurt SEO, while SSR and prerendering send crawlers a fully rendered HTML document.
  • Angular Universal was merged into the Angular CLI in version 17, and server-side rendering now lives in the @angular/ssr package.
  • Per-route render modes in app.routes.server.ts let you prerender stable pages, server-render dynamic ones and leave private screens client-rendered.
  • Google's JavaScript SEO guide says rendering might be skipped for pages that do not return a 200 status, so an Angular not-found page should return a real 404 rather than a 200.
  • Googlebot can render JavaScript, but Google also says not all bots can, so check the raw HTML with curl instead of trusting the browser.
On this page

Angular is not bad for SEO, but a default client-rendered Angular app sends a near-empty HTML shell and builds the page in the browser. Googlebot can usually run that JavaScript. Crawlers that do not run it see only the shell, and in Vercel and MERJ's December 2024 measurements that included the major AI crawlers they tracked (details in do AI crawlers run JavaScript). Server-side rendering (SSR) or prerendering with @angular/ssr puts the content into the HTML your server sends, so every kind of crawler gets it.

This guide covers how to check what your app sends, how to turn on SSR or prerendering, how to set metadata per route, and how to avoid the two traps that catch Angular apps: soft 404 pages and content that only appears after the client starts. Fixing these removes technical barriers. It does not promise rankings or citations.

Is Angular bad for SEO? What a client-rendered app sends

Angular's own SSR guide describes client-side rendering (CSR) as the default Angular behaviour. It also says CSR may hurt SEO because search crawlers limit how much JavaScript they execute, while SSR and prerendering generally do well because crawlers receive a fully rendered HTML document.

In practice, a client-rendered page looks like this to a crawler that does not run scripts:

html
<body>
  <app-root></app-root>
  <script src="main.js" type="module"></script>
</body>

The component element is empty until the browser runs the bundle. Google's JavaScript SEO basics say Googlebot crawls, renders and then indexes pages, and that server-side or pre-rendering is still worthwhile because not all bots can run JavaScript. The safe assumption for AI crawlers is that they read only the server HTML.

The problem is not Angular. It is the rendering mode. The general pattern is covered in client-side rendering and the empty HTML problem.

How to check the raw HTML of an Angular page

Do not use the browser's Elements panel, which shows the page after scripts have run. Fetch the response body instead and search it for a sentence you can see on the page.

bash
curl -s https://example.com/pricing | grep -c "Plans start at"

A count of 0 means that sentence is not in the HTML the server sent. Repeat it for the <title>, the meta description and a heading:

bash
curl -s https://example.com/pricing | grep -iE "<title>|<meta name=\"description\"|<h1"

If the title is the same on every route, or the <h1> is missing, you are serving the shell. See your page as an AI crawler with curl shows how to send a crawler user agent, and raw vs rendered HTML explains the comparison.

Angular SSR, prerendering and hybrid rendering with @angular/ssr

Angular Universal was merged into the Angular CLI repository in version 17, and the Universal repository is archived. Most of its code now lives in @angular/ssr. At the time of writing, Angular's guide gives two ways to start:

bash
ng new --ssr        # new project
ng add @angular/ssr # existing project

You then choose a rendering mode per route. Angular documents three in RenderMode:

ModeWhat it doesGood for
RenderMode.PrerenderGenerates the HTML at build time (SSG)Marketing pages, docs, blog posts
RenderMode.ServerRenders on the server for each request (SSR)Pages that change per request
RenderMode.ClientRenders in the browser (CSR)Logged-in screens nobody needs to crawl

The choices live in a ServerRoute array, which you register with provideServerRendering(withRoutes(serverRoutes)). This is Angular's own example, trimmed:

ts
import {RenderMode, ServerRoute} from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
  {path: '', renderMode: RenderMode.Client},
  {path: 'about', renderMode: RenderMode.Prerender},
  {path: 'profile', renderMode: RenderMode.Server},
  {path: '**', renderMode: RenderMode.Server},
];

Notice that the example's home route is client-rendered. For a site you want crawled, set your public routes to Prerender or Server, not Client.

Prerendering routes with parameters

A prerendered route with a parameter, such as post/:id, needs getPrerenderParams. It runs at build time and returns the parameter values to generate:

ts
{
  path: 'post/:id',
  renderMode: RenderMode.Prerender,
  async getPrerenderParams() {
    const ids = await fetchPostIds(); // your own data source
    return ids.map((id) => ({id}));
  },
},

Angular says that when a prerendered path was not generated, the fallback property decides what happens. PrerenderFallback.Server is the default and renders on the server, PrerenderFallback.Client falls back to CSR, and PrerenderFallback.None means the server will not handle the request. Pick Server for content that can appear after a build, so a new post is not served as an empty shell.

Fully static output

By default, Angular's guide says it generates a server file. Setting outputMode to static in angular.json produces prerendered HTML files for each route at build time, with no server file and no Node.js server. That suits a brochure site on static hosting, but it cannot serve routes that need per-request rendering.

Setting the title, meta description and canonical per route

With SSR, metadata set during the server render ends up in the HTML. Angular gives you three tools.

Title. A route can carry a title, and Angular's routing guide says it updates the page title when the route activates. It can be a string or a ResolveFn for dynamic values:

ts
const routes: Routes = [
  {path: '', component: Home, title: 'Home page'},
  {path: 'products', component: Products, title: titleResolver},
];

For a shared suffix, extend TitleStrategy. The Title service has getTitle() and setTitle().

Meta description. Angular's Meta service manages <meta> tags and its documentation names SEO as a use. Call updateTag so you replace the tag instead of adding a second one:

ts
private readonly meta = inject(Meta);

ngOnInit() {
  this.meta.updateTag({name: 'description', content: 'Plans, limits and pricing.'});
}

Canonical. I found no dedicated canonical API in Angular's documentation. A common approach is to inject the DOCUMENT token, which Angular's guide recommends over the global document, and set a <link rel="canonical"> there. Google says HTML is the preferred place for the canonical, that JavaScript must not change it to a different URL than the one in the original HTML, and that a page should have only one. See canonical tags and duplicate URLs for the rules.

Do not assume any of this works. Run the curl | grep check from earlier on three different routes and confirm each has its own title and description in the raw response.

Router setup: real paths and genuine 404 responses

Use path URLs, not fragments. Google says Googlebot cannot reliably resolve fragment URLs such as #/products, and recommends real <a href> links with the History API. Angular's HashLocationStrategy stores routes after a #. The documentation I fetched does not say which strategy is the default, so check that your app does not call withHashLocation() or provide HashLocationStrategy. Use routerLink on anchors so links have real href values, as covered in JavaScript links and crawler discovery.

Make not-found pages return 404. Angular's routing guide describes a wildcard route, {path: '**', component: NotFound}, as the way to show a page-not-found component. It does not say that the route changes the HTTP status, so a not-found screen can come back as 200. That is a soft 404, and Google says it may skip rendering for non-200 pages. Google's own options for client-rendered apps are to redirect with JavaScript to a URL that returns a real 404, or to add a noindex robots meta tag to error pages. See soft 404 pages.

With SSR you can set the status directly. A ServerRoute on a server-rendered path accepts status and headers, and Angular also provides the RESPONSE_INIT token for values you only know at runtime. It is typed ResponseInit | null, and Angular says it can be null in the browser and during static site generation. So it applies to request-time SSR, not prerendered pages. Prerendered routes do not accept a status property in the API reference.

Test it, because the docs do not show a 404 example:

bash
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/this-page-does-not-exist

Expect 404. If you see 200, you have a soft 404.

Hydration and content that appears only after the client starts

Server rendering only helps for what the server renders. Content added after the client starts is still missing from the HTML. Typical causes are data loaded in afterNextRender, content shown only when a browser-only flag is true, or window and document calls that fail on the server.

Angular's guide says server code cannot use browser globals such as window, document or location, and that browser-only work belongs in afterNextRender or afterEveryRender, which run only in the browser. It also warns that using isPlatformBrowser in template @if conditions causes hydration mismatches and layout shifts. Keep your headings, copy, prices and links outside browser-only branches, and use browser-only hooks for things like analytics, charts and scroll behaviour.

Hydration happens in the browser, after the server HTML has already been sent, so it does not change what a crawler that reads only the HTML receives. The check is always the raw response.

How to test with and without JavaScript

  1. Raw HTML: run the curl checks above on a template of each type: home, list, detail, not-found.
  2. JavaScript off: open the page with scripts disabled in DevTools and confirm the main text, headings and links are still there.
  3. Status codes: check the home page returns 200, a redirect returns 301 or 308, and a missing path returns 404.
  4. After every deploy: repeat the curl check, because a change to a server route can quietly return a page to client rendering.

Run these against the deployed URL, not only ng serve, because hosting, caching and server configuration are part of what crawlers receive.

Frequently asked questions

Does Googlebot index Angular apps without SSR?

Often, yes. Google documents that it crawls, renders and indexes JavaScript pages. It also says rendering might be skipped for non-200 pages, and that server-side or pre-rendering is still worthwhile because not all bots can run JavaScript.

What replaced Angular Universal?

Angular Universal was merged into the Angular CLI in version 17, and most of its code now lives in the @angular/ssr package. Angular's current docs use ng add @angular/ssr.

Should I prerender or use SSR?

Prerender pages whose content is the same for everyone, because the HTML is built once. Use SSR for pages that depend on the request. Angular's guide says you can mix modes per route.

Do I need dynamic rendering for an Angular app?

Usually not if you can use SSR or prerendering. Google describes dynamic rendering as a workaround and not a recommended solution, and suggests server-side rendering, static rendering or hydration instead. It is covered in prerendering and dynamic rendering for crawlers.

Will SSR get my Angular site cited by AI search tools?

No promise. SSR makes your content readable to crawlers that do not run JavaScript. Whether an assistant cites a page depends on many factors outside your site.

Check what your Angular pages send

The free check reads one page the way AI crawlers do, with no account, and shows whether your main text is in the raw HTML. If you want every template on a large app reviewed, an audit covers up to 500 pages with evidence and prioritized fixes. To compare options for other frameworks, see SSR, SSG and CSR for AI search.

Filed under Rendering and content. Topics: angular, javascript, ssr, rendering, ai-crawlers, troubleshooting