Jump to content

MarkupSitemap


Mike Rockett

Recommended Posts

1 hour ago, virtualgadjo said:

Hi @marie.mdna

if i'm not wrong this depends on your config file $config->httpHosts var, if the first host in the array contains the www, the sitemap will use it too (at least, that's what happens for all the websites, a lot..., for which i've this module installed ?

have a nice day

perfect! That's the point I got missing!

Link to comment
Share on other sites

On 11/9/2022 at 11:02 AM, virtualgadjo said:

Hi @marie.mdna

if i'm not wrong this depends on your config file $config->httpHosts var, if the first host in the array contains the www, the sitemap will use it too (at least, that's what happens for all the websites, a lot..., for which i've this module installed ?

have a nice day

It's important that this is the case too because otherwise you could potentially be informing search engines you are using a different primary domain to one your site it actually using.

Edited by Guy Incognito
Spotted a typo
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 11/9/2022 at 2:39 PM, Guy Incognito said:

It's important that this is the case too because otherwise you could potentially be informing site engines you are using a different primary domain to one your site it actually using.

Indeed, I tried the module for the first time on a test website where I didn't care much about any SEO (so nothing had been really set for this purpose) but was then testing for upcoming projects!

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Hi @Mike Rockett I just discovered that the sitemap is always generated, no matter what cache settings. 

In https://github.com/mikerockett/markup-sitemap/blob/2db851e9bc3e7147879dced1bcfe515cd86562a8/MarkupSitemap.module.php#L269 the generation is done before checking for cache and returning cached output.

I amended the method to read

  protected function getSitemap(string $rootPage): string
  {
    
    // Bail out early if debug mode is enabled, or if the
    // cache rules require a fresh Sitemap for this request.
    if ($this->requiresFreshSitemap()) {
      $sitemap = $this->buildNewSitemap($rootPage);
      return $sitemap;
    }

    // Cache settings
    $cacheTtl = $this->cache_ttl ?: 3600;
    $cacheKey = 'MarkupSitemap';
    $cacheMethod = $this->cache_method ?: 'MarkupCache';

    // Attempt to fetch sitemap from cache
    $cache = $cacheMethod == 'WireCache'
      ? $this->cache
      : $this->modules->MarkupCache;

    $output = $cache->get($cacheKey, $cacheTtl);

    // If output is empty, generate and cache new sitemap
    if (empty($output)) {
      header('X-Cached-Sitemap: no, next-request');
      $sitemap = $this->buildNewSitemap($rootPage);

      $output = $sitemap;

      if ($cacheMethod == 'WireCache') {
        $cache->save($cacheKey, $output, $cacheTtl);
      } else {
        $cache->save($output);
      }

      return $output;
    }

    header('X-Cached-Sitemap: yes');

    return $output;
  }

This seems to be working fine.

  • Like 1
Link to comment
Share on other sites

The other thing that I think should be implemented is a better cache expiry option - given how infrequently sitemap.xml files are called by search engines, I don't really think any sort of time based expiry is much use in reality. I think it should support wireCache's selector option (set to expire when any page is saved - although on regularly updated sites, even this might not result in the cache being used very often).

  • Like 1
Link to comment
Share on other sites

Hi guys,

I'm afraid I don't have the time to maintain this module, and would prefer if someone took it over, along with Jumplinks. The simple reality is that I don't do website development anymore and, by extension, don't use PW anymore, and so I feel it best that these modules be handed over to someone who is active with PW and would be happy to take them over. If you'd like to do so, please drop me a DM and we can take it from there.

Link to comment
Share on other sites

  • 2 months later...

Hi all,

I've released 0.9.0, which brings the minimum PHP version to 7.4, adds support for PHP 8, and adds support for Composer 2.

Also released 0.9.1 which handles @gebeer's suggestion (thanks!).

Note, however, that I've published these versions on a hunch that they will be ok – I do not have a PW setup for testing. If something is broken, let me know and I'll fix it.

  • Like 4
Link to comment
Share on other sites

  • 5 months later...
  • 7 months later...

Hey @Mike Rockett, thanks for this module! ? 

I was wondering whether it's already possible to exclude certain languages, e.g. using a hook. I have a website that has a few languages installed, but one language is used only for internal stuff and the pages should not be accessed from the outside. What can I do to prevent MarkupSitemap from outputting links to page versions using one specific language completely (even if the language version is "active" on many pages)?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...