Angular (6) SSR doesn’t appear to be a path to AMP just yet

Vijay Goel, MD
Building the Stack
Published in
2 min readJun 27, 2018

Took advantage of NX/ monorepo to break a marketing website up into admin and public versions. On the public version, I’ve been able to use JSON-LD/ schemas + SSR + meta markup to substantially improve SEO and social sharing.

Was hoping this would also be a path to getting to try to create an AMP version of the site as a separate app, pulling from ngrx and other things in a shared library (with different index.html page and markup). However, it appears that AMP markup, even after you have a SSR site, requires the elimination of angular default tags like app-root, app-container, router-outlet, routerlink, etc as well as a bunch of the script tags at the bottom of the page.

You can play with a version that deploys to heroku here(fork of the angular-universal-starter-heroku) https://github.com/goelinsights/universal-starter-amp-heroku

<!DOCTYPE html><html amp="" lang="en"><head><meta charset="utf-8"><title>NgUniversalDemo</title><base href="/"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><style amp-boilerplate="">body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript><script async="" src="https://cdn.ampproject.org/v0.js"></script><link href="styles.9c0ad738f18adc3d19ed.bundle.css" rel="stylesheet"></head><body><app-root ng-version="5.2.2">  <h1>Universal Demo using Angular and Angular CLI</h1>  <a routerlink="/" href="/">Home</a>  <a routerlink="/lazy" href="/lazy">Lazy</a>  <a routerlink="/lazy/nested" href="/lazy/nested">Lazy_Nested</a>  <router-outlet></router-outlet><app-home><h3>Hello</h3></app-home>  </app-root><script type="text/javascript" src="inline.1aaf55212d3582ec4d6b.bundle.js"></script><script type="text/javascript" src="polyfills.4983b730fd8aea4536f3.bundle.js"></script><script type="text/javascript" src="main.94e2f9a3c9cf0893ac06.bundle.js"></script><script id="my-app-state" type="application/json">{}</script></body></html>

--

--

Vijay Goel, MD
Building the Stack

Improving operations via technology and structured thinking (current focus chefs and catering)