Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-7049

Install the canonical and refresh Mediawiki extension in dev docs

XMLWordPrintable

      Summary

      We want, for pages @ https://docs.moodle.org/dev that already have been migrated to the new https://moodledev.io to be able to do a couple of thigs:

      1. We want to be able to add the rel=canonical tag, so search engines and other start indexing the new dev docs pages instead of the old ones.
      2. We want to be able to add the meta=refresh tag, so anybody visiting the old page is automatically redirected to the new one.

      To achieve this, the CarenodiMW mediawiki extension has been created.

      Actions

      1. Install the extension to be enabled for dev docs (if possible, only for dev docs, not needed for user docs).
      2. Configure it as follows. Note that the configuration only enables the rel=canonical tag, so search engines will start to be aware of the new docs. We'll enable the automatic redirects (meta=refresh in a (near) future.

        // Load the CarenodiMW extension
        if (file_exists("$IP/extensions/CarenodiMW/extension.json")) {
            wfLoadExtension('CarenodiMW');
            // Register the config.
            $wgConfigRegistry['CarenodiMW'] = 'GlobalVarConfig::newInstance';
         
            // Base URL to be used for all the canonical and refresh tags.
            $wgCarenodiMW_base = 'https://moodledev.io';
         
            // Regular expression to extract the path for the canonical tags.
            $wgCarenodiMW_canonical_regexp = '/\{\{Template:Migrated\|newDocId=(.*)\}\}/';
         
            // Regular expression to extract the path for the refresh tags.
            $wgCarenodiMW_refresh_regexp = ''; // Disabled for now.
         
            // Number of seconds to perform the refresh to new URL (0 = immediate).
            $wgCarenodiMW_refresh_wait = 0;
        }
        

      3. Verify that it's working as expected:
        1. Visit any page in mediawiki dev docs that has been already migrated to the new system (so it has the "This content of this page has been updated and migrated..." notification on top).
        2. Examine its HTML.
        3. Verify that it has a rel=canonical link in the <head> element pointing to the new docs. It should look like this:

          <html>
            ...
            <head>
              ...
              <link rel="canonical" href="https://moodledev.io/NEW/PATH/GOES/HERE">
              ...
          

        4. Verify that the URL exists in the new dev docs system and corresponds with the original @ Mediawiki.
        5. Visit any page that has NOT been migrated yet.
        6. Examine its HTML.
        7. Verify that it DOES NOT contain any rel_canonical link.

            mudrd8mz David Mudrák (@mudrd8mz)
            stronk7 Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.