chriskyfung / amp-affiliately-jekyll-theme

An AMP-Ready Jekyll Blog Theme
https://chriskyfung.github.io/amp-affiliately-jekyll-theme/
MIT License
19 stars 12 forks source link

🩹 fix (ci): AMP optimizer warning associated with jekyll-redirect-from plugin #49

Closed chriskyfung closed 9 months ago

chriskyfung commented 9 months ago

Description

When using AMP optimizer to process our Jekyll site built with Gulp, we encounter a number of warning messages like this: AMP Optimizer AddMandatoryTags WARNING No canonical param is given. Setting canonical href to .

We have traced the source of the issue to the jekyll-redirect-from plugin, which generates redirect pages with missing the HTML <head> and <body> tags. This is incompatible with the AMP optimizer and causing issues in the AMP pages.

Steps to reproduce

Expected result

The redirect pages should have absolute URLs for their canonical links, and the AMP optimizer should not show any warning messages.

Actual result

The AMP optimizer cannot ampify the redirect pages appropriately and shows warning messages like this: AMP Optimizer AddMandatoryTags WARNING No canonical param is given. Setting canonical href to .

Proposed solution

One possible solution is to customize the redirect template for the jekyll-redirect-from plugin. We can copy the redirect.html file to the _layouts directory under the Jekyll project. In the custom redirect template, we then add back the HTML <head> and <body> tags.

Steps to implement the solution