1

I was hoping to find an example on Google but couldn't find any that is specific to Razor Pages. There are a couple on MVC but MVC uses a slightly different view model.

My app is a blog. So I have a startpage with a list of blogposts and a blogpost details page and that's it.

SEO: I'm thinking.... maybe it is enough to just create a AMP .cshml template (setting Layout to null) that be done with it. Would that work or would I be missing something?

The goal is to serve those AMP pages so that Google can index them and list them in search results for mobile users. After the mobile user clicks on an AMP page if they want to see more posts they can simply click on the homepage link at the top of the page.

I'm mostly just thinking out loud here since I don't have a clear picture of how to implement this in the best possible way.

So the question is: Would a specific AMP .cshtml page be enough and are there any other Razor Pages configuration stuff I need to take into consideration? Routing for instance?

Edit: This question is specific to Razor Pages => no dupe. MVC != Razor Pages.

Maybe this could work?

@page "/amp/{slug}"
@model BlogPostModel
@{
    ViewData["Title"] = Model.BlogPost.Data.Title;
    Layout = "_LayoutAmp";
}

/* markup */
PussInBoots
  • 11,028
  • 9
  • 52
  • 84
  • Possible duplicate of [Automatically switching views for AMP in ASP.NET MVC](https://stackoverflow.com/questions/49127913/automatically-switching-views-for-amp-in-asp-net-mvc) – Chris Pratt Oct 31 '18 at 19:04
  • I don't think AMP is going to work well with Razor Pages without a lot of code duplication. I'd suggest using MVC at least for the routes you want to have both HTML and AMP representations for. – Chris Pratt Oct 31 '18 at 19:06

0 Answers0