Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Alex Skrypnyk 6079 posts 23436 karma points MVP 6x admin c-trib
    Nov 21, 2019 @ 00:45
    Alex Skrypnyk

    Recently I got a task to make existing blog AMP compatible.

    Can somebody recommend the steps? What should I do first?

    Thanks, Alex

  • Chriztian Steinmeier 2770 posts 8607 karma points MVP 6x admin c-trib
    Nov 21, 2019 @ 05:28
    Chriztian Steinmeier

    Hi Alex,

    I remember Carole wrote about this at some point. Don’t know how much is still valid but you can take a look:


  • Paul Seal 516 posts 2840 karma points MVP 5x c-trib
    Nov 21, 2019 @ 08:02
    Paul Seal

    I did it using an alt template and therefore adding /amp/ to the url

  • Alex Skrypnyk 6079 posts 23436 karma points MVP 6x admin c-trib
    Nov 21, 2019 @ 10:50
    Alex Skrypnyk

    Thanks for recommendations! #h5yr!

  • Paul Seal 516 posts 2840 karma points MVP 5x c-trib
    Nov 21, 2019 @ 10:58
    Paul Seal

    Here's the template I used, it's a bit hard coded but you might find it a good starting point.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
        Layout = null;
        string pageTitle = Model.Content.GetPropertyValue<string>("pageTitle");
        string imgUrl = "";
        if (Model.Content.HasValue("pageBannerImage"))
            imgUrl = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("pageBannerImage").Url;
    <!doctype html>
    <html amp>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <title>@(Model.Content.HasValue("pageTitle") ? pageTitle : Model.Content.Name)</title>
    <link rel="canonical" href="@Model.Content.Url"/>
    <script src="" async></script>
    <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 custom-element="amp-analytics" src=""></script>
    <amp-analytics type="googleanalytics" id="analytics1">
    <script type="application/json">
      "vars": {
        "account": "UA-12345528-1"
      "triggers": {
        "trackPageview": {
          "on": "visible",
          "request": "pageview"
    <nav class="amp-wp-title-bar">
    <a href=""> </a>
    <div class="amp-wp-content">
    <h1 class="amp-wp-title">@(Model.Content.HasValue("pageTitle") ? pageTitle : Model.Content.Name)</h1>
    <ul class="amp-wp-meta">
    <li class="amp-wp-byline">
    <span class="amp-wp-author">Paul Seal</span>
    <li class="amp-wp-posted-on">
    <time datetime="@(Model.Content.GetPropertyValue<DateTime>("blogPostDate").ToString("yyyy-MM-ddTHH:mm:sszzz", System.Globalization.CultureInfo.InvariantCulture))">
    @CodeShare.Library.Utility.Social.General.GetRelativeTime(Model.Content.GetPropertyValue<DateTime>("blogPostDate") ) </time>
    <a href="[email protected]" rel="nofollow">
    <amp-img src="" alt="FB-Share" width="105" height="39" class="amp-wp-enforced-sizes"></amp-img>
    <a href="[email protected](Model.Content.HasValue("pageTitle") ? pageTitle : Model.Content.Name)&[email protected](Model.Content.Url)&via=CodeSharePaul" rel="nofollow">
    <amp-img src="" alt="Tw-Share" width="105" height="39" class="amp-wp-enforced-sizes"></amp-img>
    <div class="media-credit-container alignnone"><amp-img class="size-full wp-image-264208 amp-wp-enforced-sizes" src="@imgUrl" alt="@Model.Content.Name" width="1200" srcset="@(imgUrl)?width=1200&mode=crop&anchor=center 1200w, @(imgUrl)?width=622&height=350&mode=crop&anchor=center 622w" sizes="(min-width: 800px) 800px, 100vw" height="675"></amp-img></div>
    @Html.GetGridHtml(Model.Content, "contentGrid", "Amp")

    And in my master template I have this for rendering the amp url in the head

    @if (Model.Content.HasValue("enableAmp") && (bool)Model.Content.GetPropertyValue<bool>("enableAmp"))
        <link rel="amphtml" href="@(Model.Content.Url)amp/" />

    I hope that helps


  • Paul Seal 516 posts 2840 karma points MVP 5x c-trib
    Nov 21, 2019 @ 11:01
    Paul Seal

    Finished editing it now 😀

  • Carlos Mosqueda 239 posts 429 karma points
    Apr 07, 2020 @ 21:57
    Carlos Mosqueda


    When you did the amp template. How is the alt template URL /amp/ ? How does that work. We are using Umbraco 7.12 still is it different in Umbraco 8? We get a 404 with the "/amp/" at the end of the URL.

Please Sign in or register to post replies

Write your reply to: