[SOLVED] Routes.yaml for AMP


(Benjamin S) #1

Hi there,

I’m implementing AMP based on Sebobo/Shel.Blog.

I also set up the routes so that my pages are available via /amp/[urlPathSegment].html.

Now I’m struggling with the home page. I want it to be accessible via /amp oder /amp.html, but you can only get there via /amp/.html.

This is my Routes.yaml file:

-
  name: 'AMP homepage'
  uriPattern: 'amp/{node}'
  defaults:
    '@package': 'Neos.Neos'
    '@controller': 'Frontend\Node'
    '@action': 'show'
    '@format': 'html'
    '--page-amplify': true
  routeParts:
    'node':
      handler: 'Neos\Neos\Routing\FrontendNodeRoutePartHandler'

-
  name:  'AMP pages'
  uriPattern: 'amp/{node}<defaultUriSuffix>'
  defaults:
    '@package': 'Neos.Neos'
    '@controller': 'Frontend\Node'
    '@action': 'show'
    '@format': 'html'
    '--page-amplify': true
  routeParts:
    'node':
      handler: 'Neos\Neos\Routing\FrontendNodeRoutePartHandler'

Changing defaultUriSuffix to an empty string unfortunately doesn’t help.

In other words: I don’t get the amp/{node} part. As far as I can tell {node} for the home page is empty. But it will still take the ‘AMP Pages’ route.

Can anybody help me? :slight_smile:

Cheers


(Sebastian Helzle) #2

Hi Benjamin,

cool that you use my implementation :slight_smile: Did you extract the parts that you need, or did you extend my blog package?
Would be interested to have at some point a package that makes AMP easier for a whole site.
But there are many hurdles on the way to keep it stable and not breaking with other plugins etc…

Regarding your issue, you can try adding the following (untested) route as we had a similar issue in the SEO package with the robots.txt:

-
  name:  'AMP pages'
  uriPattern: '{node}amp
  defaults:
    '@package': 'Neos.Neos'
    '@controller': 'Frontend\Node'
    '@action': 'show'
    '@format': 'html'
    '--page-amplify': true
  routeParts:
    'node':
      handler: 'Neos\Neos\Routing\FrontendNodeRoutePartHandler'

(Benjamin S) #3

Thanks, Sebastian! Using 'amp{node}' now seems obvious. :slight_smile:

I created a new package for our websites based on your blog package and added things like Google Tag Manager, Cookie Notice and a switch to disable AMP for certain pages. I also had to rebuild parts of our CSS, because we used a lot from Foundation that blew the 50 KB limit.

We hadn’t AMP in mind when creating our sites so I am basically rebuilding most parts of them (header, logo, menus, footer, etc.). Neos works great as CMS for multiple purposes and your blog package is a great start. Thank you! :slight_smile:


(Sebastian Helzle) #4

Great!