We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1198
    • 6 Posts
    Hi,

    I’m not sure if this is the right place to make suggestions for changes, so apologies if it’s not!

    Anyway, I have a proposal for a change to manager/includes/document.parser.class.inc.php

    MODX out of the box adds the meta tags into the template HTML immediately after the opening <head> tag of the document. This is the wrong position for the meta keywords and description tags. For reference, please read this excellent article: http://www.joelonsoftware.com/articles/Unicode.html

    It would be convenient if you could put the Content-Type of the HTML file right in the HTML file itself, using some kind of special tag. Of course this drove purists crazy... how can you read the HTML file until you know what encoding it’s in?! Luckily, almost every encoding in common use does the same thing with characters between 32 and 127, so you can always get this far on the HTML page without starting to use funny letters:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    But that meta tag really has to be the very first thing in the <head> section because as soon as the web browser sees this tag it’s going to stop parsing the page and start over after reinterpreting the whole page using the encoding you specified.

    My proposal is to modify line 647 in document.parser.class.inc.php as follows:

        // if ($metas) $template = preg_replace("/(<head>)/i", "\\1\n\t" . trim($metas), $template);
        if ($metas) $template = preg_replace("/(<title>([^>]*)<\/title>)/i", "\\1\n\t" . trim($metas), $template);
    


    This will then insert the meta tags after the <title></title> tags, allowing the template creator to specify the charset immediately after the opening <head> tag. This will allow better support for internationalization.

      • 25663 MODX Staff
      • 12,272 Posts
      The built in meta tags and keywords functionality has been deprecated and will be removed from a future Evo release, and is not even in Revo at all. You should use TVs for this purpose.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 1198
        • 6 Posts
        Ah, an even easier solution!

        Thanks