ethercreative/seo

The idea of rendering the template manually seems wrong

dubcanada opened this issue · 3 comments

Hello,

I love this plugin but the idea that it takes the content, and renders it manually rather then just doing like a curl call to /uri and read that seems wrong to me.

In order to accurately determine SEO it should follow the same flow as Google Bot or anything else uses, and do something like file_get_contents('/URI'); to get the entire HTML source (or get it from Live Preview somehow) and use that in the SEO determination. Rather then manually rendering each field.

This would also remove all of the readability, and field template settings. Which just seem to add a layer of complexity that provides no benefit. Google doesn't selectively read your fields a certain way and not some. It reads the entire page, and this plugin should do the same.

Basically my proposal is to change _showEntry to something like

private function _showEntry (EntryModel $entry) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $entry->url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

    $output = curl_exec($ch);
    curl_close($ch);

    HeaderHelper::setContentTypeByExtension('html');
    HeaderHelper::setHeader(array('charset' => 'utf-8'));
    ob_start();
    echo strip_tags($output, '<p><h1><h2><h3><h4><h5><h6><a><img><b><strong>');
    craft()->end();
}

Thoughts?

Tam commented

Glad you like the plugin!

I have to agree, I've never really liked how we handle the field settings and this seems like a good fix. I'll try and find some time this week to properly look into the viability of this and what changes we'll need to make to implement it.

I think CURL would work, the only problem is if you are modifying things it doesn't get updated till after you save, but I've been played around with the regular version and it doesn't seem to update either way (at least in the live preview).

I think some sort of live preview usage may be better.

Tam commented

This has been added in dfda785 (v1.1.0)!