Jump to content
Wanze

SeoMaestro

Recommended Posts

Quote

 It is also possible to combine strings and placeholders.The following example appends the company name after a page's title: {title} | acme.com.

What would you suggest if we want to add ' | mysite.com' to the end of every page title but only set it in a single source field.

In the example above, a user would need to add acme.com to every page.

MarkupSEO had a field called Title Format where you could specify the structure of the Meta Title whether it was inherited or custom and it was very useful.

737664031_Screenshot2019-04-17at16_50_47.png.c222fd09fdf901ee74e5a226549c521c.png

The Sitename placeholder above was essentially an extra field in the config.

Could you consider something like this? I can't seem to add a custom field to the SEO module but would be happy to add one to my custom Settings page (a simple private PW page).

 

 

Share this post


Link to post
Share on other sites

Hi @Wanze
 

If we want to output just the opengraph tags, the instructions provided work
`echo $page->seo->opengraph->render();`

But what is the syntax to just echo the robots tag ?


`echo $page->seo->robots;`
Outputs 'RobotsSeoData'


`echo $page->seo->robots->render();`
Outputs nothing

Share this post


Link to post
Share on other sites

Hello @Peter Knight

I think that there is no render tag method for the robot tags, but you can use the following:

$page->seo->robots->data['noIndex']
$page->seo->robots->data['noFollow']

This returns true if 'no index' was choosen and true if 'no follow' was choosen. Create the meta tags by yourself and use PHP to fill in these values into the meta tags.

Best regards Jürgen

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Juergen said:

Hello @Peter Knight

I think that there is no render tag method for the robot tags, but you can use the following:


$page->seo->robots->data['noIndex']
$page->seo->robots->data['noFollow']

This returns true if 'no index' was choosen and true if 'no follow' was choosen. Create the meta tags by yourself and use PHP to fill in these values into the meta tags.

Best regards Jürgen

Thanks Juergen. I’ll try that. What are the data and square brackets in terms of PHP and the API?

Share this post


Link to post
Share on other sites
On 4/17/2019 at 6:01 PM, Peter Knight said:

What would you suggest if we want to add ' | mysite.com' to the end of every page title but only set it in a single source field.

@Peter Knight

This is currently only possible with a hook, check out the following test case: https://github.com/wanze/SeoMaestro/blob/master/tests/src/SeoMaestroTest.php#L119-L129

But this would make a nice feature, either in the module config or configurable per field. Could you open a feature request on GitHub? Thanks 🙂

Cheers

Share this post


Link to post
Share on other sites
9 hours ago, Peter Knight said:

Hi @Wanze
 

If we want to output just the opengraph tags, the instructions provided work
`echo $page->seo->opengraph->render();`

But what is the syntax to just echo the robots tag ?


`echo $page->seo->robots;`
Outputs 'RobotsSeoData'


`echo $page->seo->robots->render();`
Outputs nothing

Hi @Peter Knight,

$page->seo->robots->render() should work fine, but it only outputs the tags if you have checked any of the noIndex or noFollow options.

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
On 4/17/2019 at 7:16 AM, Juergen said:

I have not installed this module and I have the same problem. On my current installation I have only installed a few modules. So I guess it has nothing to do with other modules.

@Juergen

What version of ProcessWire and which AdminTheme are you using?

Share this post


Link to post
Share on other sites
6 hours ago, Juergen said:

Hello @Peter Knight

I think that there is no render tag method for the robot tags, but you can use the following:


$page->seo->robots->data['noIndex']
$page->seo->robots->data['noFollow']

This returns true if 'no index' was choosen and true if 'no follow' was choosen. Create the meta tags by yourself and use PHP to fill in these values into the meta tags.

Best regards Jürgen

@Juergen @Peter Knight

There is a render() method for any "group", but in case of the robots it will only return something if at least one option (noIndex, noFollow) is checked.

Your example to access the individual data is correct, you can also use the following syntax, which looks slightly nicer: $page->seo->robots->noIndex

Cheers

  • Like 3

Share this post


Link to post
Share on other sites
On 4/16/2019 at 9:20 PM, Juergen said:

Thank you @Wanze for this great module.

Only one thing to mention:

From the point of security it is not recommended to add the generator metatag (or any other information to help hackers to know something about the system).

 So it would be great to add a setting checkbox to disable the rendering of this metatag. I know I can render each metatag separately but using your render method ($page->seo->render()) would be much more comfortable 🙂.

Best regards Jürgen

@Juergen

I think that a hacker will easily find other ways to determine the underlying CMS by inspecting the markup or headers (or https://builtwith.com/). But I see your point 🙂

For now, you can use a hook to disable the generator tag:

        $wire->addHookAfter('SeoMaestro::renderMetatags', function (HookEvent $event) {
            $tags = $event->arguments(0);
            $group = $event->arguments(1);

            if ($group === null) {
                unset($tags['meta_generator']);
                $event->return = $tags;
            }
        });

Feel free to open a feature request on GitHub.

Cheers

  • Like 3

Share this post


Link to post
Share on other sites
Posted (edited)
17 hours ago, Wanze said:

Hi @Peter Knight,

$page->seo->robots->render() should work fine, but it only outputs the tags if you have checked any of the noIndex or noFollow options.

Cheers

Something must not be setup properly at my end.

Using the following

<?php echo $page->seo->robots->render(); ?>

I can get a page to produce this

<meta name="robots" content="noindex, nofollow">

Regardless of what I try, I cannot get SEOMaestro to produce the opposite 

<meta name="robots" content="index, follow">

@Wanze UPDATED: After a little more research, I have discovered that index, follow are the default for search engines and don't need to be specified so it appears as if your module is functioning as it should.

 

In the Admin itself, I have the following set

  • Fields > seo > Robots = both unchecked
  • Page 01 > seo >  Robots > NoIndex = Inherit =  unchecked. Prevent... = checked
  • Page 01 > seo >  Robots >  NoFollow = Inherit =  unchecked. Prevent... = checked

Result on Page 1 output

<meta name="robots" content="noindex, nofollow">

On the other hand, if I do this

  • Fields > seo > Robots = both unchecked
  • Page 01 > seo >  Robots > NoIndex = Inherit =  unchecked. 
  • Page 01 > seo >  Robots >  NoFollow = Inherit =  unchecked. 

Output is blank.

 

I'll bypass it for the moment and make a custom field but it'd be good to know what I might be doing incorrectly if you get a chance.

 

Edited by Peter Knight
Found solution to my issue

Share this post


Link to post
Share on other sites
18 minutes ago, Peter Knight said:

Regardless of what I try, I cannot get SEOMaestro to produce the opposite

@Peter Knight

That's because the opposite (index,follow) is assumed by default and you do not need the meta tags at all in this case. The module does only render them if you have checked at least one (noindex or nofollow).

  • Like 1

Share this post


Link to post
Share on other sites
33 minutes ago, Wanze said:

@Peter Knight

That's because the opposite (index,follow) is assumed by default and you do not need the meta tags at all in this case. The module does only render them if you have checked at least one (noindex or nofollow).

Thanks. I updated my post just before I saw this. Never realised that!

  • Like 1

Share this post


Link to post
Share on other sites

I added this module to my site to test it. I see this error:


Parse Error: syntax error, unexpected '?' (line 49 of /home/desert1/public_html/mytest/site/modules/SeoMaestro-master/InputfieldSeoMaestro.module.php) 

PW lastest DEV release. Thanks

Share this post


Link to post
Share on other sites

@nfil

are you running a PHP version older than 7.0? It seems this shorthand syntax ("syntactical sugar") has only been added with PHP 7.

line 49 is:

$isTranslatable = $info['translatable'] ?? false;

https://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op

https://lornajane.net/posts/2015/new-in-php-7-null-coalesce-operator

  • Like 3

Share this post


Link to post
Share on other sites

thanks dragan! The server was running an older PHP version.

Share this post


Link to post
Share on other sites

I wanted to create a HTML Sitemap with the same pages as the XML sitemap.

Unfortunately the $pages->find() method doesn´t support the order of the page tree, so I could not use the provided function to get all pages from the XML-Sitemap in the same order as the page tree.

$pages->find('seo.sitemap_include=1');

So I wrote a little recursive function to render all the pages except the ones which were not included in the XML sitemap. The pages have the same order as in the page tree.

function renderSitemap($items, $depth = 0)
    {
        $separator = '';
        for ($x = 0; $x <= $depth; $x++) {
            $separator .= '-';
        }
        foreach ($items as $item) {
            if ($item->seo->sitemap->include == 1) {
                $subitems = $item->children();
                if (count($subitems)>0) {
                    echo '<b>'.$separator.$item->title . '</b><br />';
                } else {
                    echo $separator.$item->title . '<br />';
                }
                $subitems = $item->children();
                renderSitemap($subitems, $depth+1);
            }
        }
    }

//OUTPUT INSIDE TEMPLATE FILE
$items = $pages->get("/")->children();
echo '-'.$pages->get("/")->title.'<br />';//this is only for the homepage
renderSitemap($items);

This little function is not intended as a complete HTML sitemap markup generation solution. It only outputs the title of the pages (without links). It should only be a starting point for others to show you how to use SEOMaestro settings in combination with a frontend sitemap. Maybe if someone has a better solution it would be great if you post it here.

Best regards

This is what it looks like:

screenshot-localhost-2019.04.24-14-36-40.png

  • Like 2

Share this post


Link to post
Share on other sites

I am encountering a weird problem.

My HTML code looks like this:

<!doctype html>
<html class="no-js" lang="" xmlns="http://www.w3.org/1999/xhtml"
  xmlns:og="http://ogp.me/ns#">
<head>
  <!-- Site Title -->
  <title><?=$page->title;?></title>

  <!-- Site Meta Info -->
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <?php echo $page->SeoMenu;?>
  .
  .

Obviously the title tag appears twice and I want to avoid it. By removing the title tag, the website becomes very slow and i am unable to acces the admin panel (stuck at loading).
The page I am working on is the homepage of the website.

Thank you.

Share this post


Link to post
Share on other sites
On 4/17/2019 at 8:16 AM, Juergen said:

I have not installed this module and I have the same problem. On my current installation I have only installed a few modules. So I guess it has nothing to do with other modules.

+1

Version: DEV (3.0.130)

AdminTheme: Uikit - defaults

2019-04-30  17.57.47.png

  • Like 3

Share this post


Link to post
Share on other sites

Is it a multi-language installation?

I guess I've seen something similar a few days ago but didn't care much about it.

Share this post


Link to post
Share on other sites
11 minutes ago, msncom said:

+1

Version: DEV (3.0.130)

AdminTheme: Uikit - defaults

+1 over here

  • Like 2

Share this post


Link to post
Share on other sites

Hi @Wanze,

is it possibile to query a ProField Matrix field (an image in this particular case) as a placeholder for the og:image setting? Something like {matrixfield.imagefield} ?

Right now the only images I have inside my templates come from a field of type Matrix.

Any solution available? 🙂

Share this post


Link to post
Share on other sites

Hi @3fingers, you could hook page save to copy first image found in the matrix to a hidden image field, then reference that. I literally just installed this module for the first time so I am not exactly sure of the correct way to do it, but you could also probably hook page save to copy the image url directly to the og:image setting. 

I came to ask a similar question, as mentioned I haven’t even tested this yet so sorry if I missed something ... if you reference a field for the description with large amounts of text does it automatically truncate the text? If not, is there a way to do this in the {field} placeholder, like {field|truncate:200} ? Would be handy.

Share this post


Link to post
Share on other sites
26 minutes ago, Mikie said:

Hi @3fingers, you could hook page save to copy first image found in the matrix to a hidden image field, then reference that. I literally just installed this module for the first time so I am not exactly sure of the correct way to do it, but you could also probably hook page save to copy the image url directly to the og:image setting. 

I came to ask a similar question, as mentioned I haven’t even tested this yet so sorry if I missed something ... if you reference a field for the description with large amounts of text does it automatically truncate the text? If not, is there a way to do this in the {field} placeholder, like {field|truncate:200} ? Would be handy.

Thanks for the suggestions, I'm going to work on those and see if I can come up with something useful.

+1 for more options for the placeholders, would be even more flexible.

Share this post


Link to post
Share on other sites

@3fingers I feel like the RuntimeMarkup module might be good for this also, although again I’ve never used it don’t know much about it. Im thinking you could create a hidden field to search your matrix and return the image url. This is what I will initially try to use to truncate my too long descriptions.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...