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

    I have a small problem when using shortcuts to the top of the home page:

    <li><a href="[~[*id*]~]#header">Return to Top</a> |</li>


    I use base URL in my template, in case this is relevent.

    This works fine, except on the home page, where the generated URL is mywebsite.com/home#header instead of mywebsite.com#header. The problem has little practical impact, as the URL is immediately redirected to mysite.com.

    However, this strikes me as probably not the best SEO. When I think about this further, it might be better to simply drop the ’header’ part, and just use [~[*id*]~] since will automatically return the top of the page. But, this still leaves ’home’ forming part of the link on the home page (even though it is redirected).

    So, I guess I have two questions:

    1. Does this behavior matter?

    2. How might I sensibly remove ’home’ from the links on the home page?

    Thanks.
      • 37272
      • 216 Posts
      Having thought about this further, I think it more logical and carries more meaning if I keep the anchor ’header’.

      My two questions still stand. Anyone?
        • 37272
        • 216 Posts
        Hi,

        I still have no solution. I would normally simply add a TV with a default value, and change it for the home page to use the full URL instead. However, my pages consist of several distinct blocks, and each block is ended, and a new block started, by placing {{break}} in the [*content*]. The closing divs in the template close the final block. My problem is that these ’Return to Top’ links are part of the {{break}} chunk, so the only way I can do this is by creating a new chunk ({{break-home-page}}, for example) that will contain the full URL for the home page instead of using [~[*id*]~]#header from the {{break}} chunk.

        I guess this is not a huge problem, but it strikes me as a sloppy solution. Has anyone a solution to stop [~[*id*]~]#header returning www.mysite.com/home#header instead of www.mysite.com#header? Surely this is a bug and must impact many situations.
          • 37272
          • 216 Posts
          Just thought I’d post the solution for anyone else to use.

          Funnily enough, I had asked a similar question to this a long time ago, but had totally forgetten about it. I think I used a different solution to the problem at the time. I tried the pluggin a couple of weeks ago, but misinterpretted it, so thought it didn’t work. I just looked at it again (interpretted it differently), and it works perfectly.

          Original post: http://modxcms.com/forums/index.php/topic,7104.msg49812.html#msg49812

          I used the following:

          $output = $modx->documentOutput;
          $urlOriginal = 'home#header';
          $urlNew = '#header';
          $modx->documentOutput = str_replace($urlOriginal, $urlNew, $output);


          Just what I needed.

          A very belated thank you to Ram.