1

I'm stuck on implementing AMP templates with category-based URLs as I can't find a way to route the different entry types in the Routes function in the CP.

I have a channel title Articles that has two entry types (Lists and Articles) with a URL format {businessCategory.first.slug}/{slug} that uses a primary category for the first segment of the URL.

I've tried */slug/amp as a route in the CP but then I can't change the AMP template for each entry type.

Any help would be greatly appreciated!

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
Scott Carr
  • 13
  • 2

1 Answers1

1

You don't strictly need to change the AMP template for each entry type; you can just load the entry in your AMP template via the slug in the URL.

Check out how I did it here: Implementing AMP in Craft CMS

andrew.welch
  • 11,551
  • 22
  • 31
  • Your article is awesome and extremely helpful! I can access the entry as you’ve indicated, but I still don’t understand how I can customize the AMP template for the two entry types that are using different templates for the non-AMP pages. – Scott Carr Feb 04 '18 at 13:11
  • Are you suggesting to use a single _amp_entry.twig file and then use Twig embed or include for the entry type templates? – Scott Carr Feb 04 '18 at 13:26
  • I'm suggesting you have a single _amp_entry.twig that extends from an _amp_layout.twig, yes. If you have more than one entry type, sure, just include a partial based on the entry type. – andrew.welch Feb 06 '18 at 05:23