While implementing yoast_seo for a client we stumbled onto two issues:

1. yoast_seo analyses the output of a rendered entity. This entity should be rendered in the frontend theme rather than using the administration theme which is active when running the AnalysisFormHandler logic. In the attached patch, an addition to the yoast_seo settings is added where you can select the theme to use when analysing.

2. Another issue we encountered is that not all <p> elements are 'detected' when analysing. We traced this problem back to the getParagraphsInTags method in https://github.com/Yoast/YoastSEO.js/blob/develop/src/stringProcessing/m..., which cannot handle newlines in the given text. This issue is solved by simply stripping all \n characters in the createEntityPreview method.

Please see the attached patch.

CommentFileSizeAuthor
frontend-theme-and-newlines.patch14.42 KBruuds

Issue fork yoast_seo-3122871

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Ruuds created an issue. See original summary.

ruuds’s picture

Issue summary: View changes

crmn made their first commit to this issue’s fork.

bramdriesen’s picture

Status: Needs review » Reviewed & tested by the community

I tested this out, this actually also fixes Acquia Site Studio compatibility!

  • Kingdutch committed eca2a887 on 8.x-2.x
    Issue #3122871 by crmn, Ruuds, BramDriesen: Analyze frontend theme and...

  • Kingdutch committed 5d876b09 on 8.x-2.x
    Issue #3122871 by crmn, Ruuds, BramDriesen, sqf: issue with missing <p>...

Kingdutch credited sqf.

kingdutch’s picture

Status: Reviewed & tested by the community » Fixed

Rather than using a global setting I've implemented this using configuration on the analysis widget. This allows different types of analysable entities to use different themes if that's desired. I've also used the opportunity to add support for view mode configuration which was a TODO that was in the code and could use the same plumbing. To top it off I've added some test coverage with Behat to confirm everything works (and keeps working) :D

I was able to copy the changes to the analyser as provided, with the adjusted plumbing for the settings.

Thanks for your help! :D This is released as 8.x-2.0-alpha9

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.