We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18367
    • 834 Posts
    In the installation instructions it says to put <base href="[(site_url)]" /> in the template head.

    According to W3C and other sources this is an incorrect use of the tag.

    as each page should serve as its own base.

    Am I missing something here or is this just an oversight?



      Content Creator and Copywriter
      • 25663 MODX Staff
      • 12,272 Posts
      In a quick perusal of the w3c site I cannot find any information that says a site-wide common base-href tag is wrong. From: http://www.w3.org/TR/html401/struct/links.html#h-12.4

      In HTML, links and references to external images, applets, form-processing programs, style sheets, etc. are always specified by a URI. Relative URIs are resolved according to a base URI, which may come from a variety of sources. The BASE element allows authors to specify a document’s base URI explicitly.

      When present, the BASE element must appear in the HEAD section of an HTML document, before any element that refers to an external source. The path information specified by the BASE element only affects URIs in the document where the element appears.

      For example...

      No mention of not using the URI to the site itself.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 18367
        • 834 Posts
        Hi Ryan,

        some background.

        I’m trying to sort out some indexing problems I’m having with Google webmaster tools.

        And several people have pointed out that having the same base href for every document is wrong, and that each page should have it’s own base.

        Now, I don’t know if they are right or not, but as several separate people have mentioned it I’m naturally starting to wonder.

        See http://chrisjdavis.org/base-href for one interpretation.

        Whether it makes that much of a difference or not I don;t know, I’m just raising the issue.
        grin



          Content Creator and Copywriter
          • 25663 MODX Staff
          • 12,272 Posts
          He’s quoting the same bit of code I put above. The W3C’s spec does not say anything other than a base href on a given page only affects the links on that page (not for the entire site). It omits any discussion about using the same base href across an entire site—and standards bodies like the W3C can tend to be explicit about things of that magnitude. I’m not prone to reading anything extra into specs that the author of a spec doesn’t explicitly state.

          The article you mentioned is also in reference to a WP blog that splits contents across multiple pages. I don’t have experience in that type of WP site, but apparently a base href in that particular case causes problems. It doesn’t in MODX.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 18367
            • 834 Posts
            Ryan,

            as I understood his article the WP case was just an example.

            The point he and others are making is that the base should refer to the location of the page or document regardless of what platform people may be using.

            Struts: The Complete Reference, 2nd Edition (Complete Reference Series)http://www.amazon.com/Struts-Complete-Reference-2nd/product-reviews/0072263865/ref=sr_1_1_cm_cr_acr_txt?ie=UTF8&showViewpoints=1 also says pretty mch the same thing.

            The base tag is used to render an HTML <base> tag with a reference pointing to the absolute location of the enclosing page. The HTML <base> tag defines the page’s URL for resolving relative URLs contained in the page.






              Content Creator and Copywriter
              • 25663 MODX Staff
              • 12,272 Posts
              The way MODX generates URLs however would not work with a full path in the base URL. A base HREF as we’ve proscribed and the relative links generated by the MakeURL functions take care of it being absolutely correct for MODX.

              I still contend the others are reading too much into the spec, if they’re referencing that specific bit of text quoted above. The W3C recommendations say absolutely nothing about unique-per-page base href tags in the text quoted above or anywhere else I’ve been able to find in the HTML 4.01 spec. Granted, I’ve barely looked and would gladly take it all back. I don’t think your quote above is from the W3C’s site, but from someone’s interpretation of it. If you’re manually making pages, I can see how if you’re making a website manually or using another CMS it definitely would make more sense to do it that way.

              But not with MODX.

              Irrespective of what’s "proper" wether it be my interpretation or someone else’s, a site-wide base href pointing to whatever your [[++site_url]] is in MODX is what works if you’re using link tags (e.g., [[~123]] ) or the API functions. I can’t think of a single negative that can come out of having a MODX-proper base href tag in your templates, and a lot that can go wrong if you don’t.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 26016
                • 561 Posts
                Interesting issue. It’s a tricky one for MODx, as it’s sort of built that way. And I’m sure it’s a great way to start an argument, just like the proponents of absolute paths vs. relative paths. Religion and politics are easier to discuss. wink

                To be sure, I have actually made a number of MODx sites with no Base Href at all, but there are some things that I think pretty much require it, like using the alias path for SEO, and what Ryan said.

                I can think of an unusual case just last week when I had to take it out. I was pulling in MachForm (third party form making app), and I made a nice little snippet that included it just beautifully, and my clients are excited because now they can make really nice forms fast without writing a line of code. As I recall, the "redirect after you’re done" part would not work with Base Href. I probably could have forced it to work by hacking MachForm code, but I took it out and all was well.
                  MODx and Wordpress development
                  Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                  • 18367
                  • 834 Posts
                  Thanks Ryan,

                  as I said I’m merely asking the question as several people made comment about it while trying to resolve some indexing issues.

                  Whether it’s "wrong", merely an "incorrect" use of the tag or as you say others are reading too much in to it I don’t know.

                  Also, whether it has any impact on SEO or indexing is also unclear.

                  If I find out anything more I’ll report back.
                  grin




                    Content Creator and Copywriter
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Guys, base href has to be the actual location of the page so that the relative links are correct. ALL pages in MODX are at the site root, served by index.php; any paths are simply virtual, not actual locations. Thus, the base href must ALWAYS be the site_url setting.
                      • 18367
                      • 834 Posts
                      OpenGeek,

                      I get it, but it sure sounds a bit Monty Python like.

                      grin


                        Content Creator and Copywriter