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!

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

| improve this answer | |
  • 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 4 '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 4 '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 6 '18 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.