Jump to content

Recommended Posts

What do you think about making the module extensible via hooks?

I had a client request a sitemap that included videos. Now, methods of storing videos differ: file fields, video URLs, embed codes, and so on. I suspect there's no straightforward way to include videos in the sitemap using just this module.

However, implementing this on a site-by-site basis would become simple if there was a way to hook into the sitemap creation process and append different definitions like video or news item yourself.

Of course, I could create the whole sitemap from scratch — but your module does a lot of things very well and I'd love to build upon that.

Share this post


Link to post
Share on other sites

Thanx for your module - MarkupSitemap, v. 0.4.1. Works perfect (PW 3.0.123)!
What about adding 'x-default', a reserved hreflang attribute, when no languages match? recommended by Google & Yandex.

 "Use the x-default tag for unmatched languages. The reserved value hreflang="x-default" is used when no other language/region matches the user's browser setting.
This value is optional, but recommended, as a way for you to control the page when no languages match."
,
google.com/webmasters/answer/189077#sitemap | webmasters.googleblog.com/.../x-default-hreflang-for-international-pages.html

<xhtml:link rel="alternate" hreflang="x-default" href="...URI-to-default-language..." />

Something like this:

hreflang-x-default.png.990282f0039da0baa083a1cb7fe86841.png

 

  • Like 1

Share this post


Link to post
Share on other sites

Google Search Console talk: "Sitemap file is in HTML format" 😭

Share this post


Link to post
Share on other sites

Hey @Mike Rockett,

Any chance you could add this module to Packagist?

Would love to use it on my current project, but I'm relying on Composer. Would be nice not to have to install this module via Git or add the repository manually to composer.json. It would also be awesome if you could declare type as pw-module and add wireframe-framework/processwire-composer-installer as a dependency for easy installing.

Thanks for considering! 👌🙂

  • Like 4

Share this post


Link to post
Share on other sites

I just installed this module as an upgrade to the Markup Sitemap XML module and I really like it, thank you!

Unfortunately, I found that adding the "license" field to a image using ImageExtra doesn't display the license despite using a valid URL: https://creativecommons.org/licenses/by-nc-nd/4.0/

Share this post


Link to post
Share on other sites

Hey @teppo - sorry for the delayed reply here. This can definitely be done. Good work with the composer installer - haven't been around for a while now, so didn't see it pop up. 🙂

Hey @Lance O. - You're very welcome - glad you like the module! 🙂 I don't think your issue is related to the URL validator, as the filter does say that URL is valid, as expected. This leads me to think that it's a spelling issue with the field name, though that seems unlikely. Would you mind doing a little debugging and checking to see if the URL does indeed get knocked out at https://gitlab.com/rockettpw/seo/markup-sitemap/blob/master/MarkupSitemap.module.php#L447?

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, Mike Rockett said:

The module has been published to Packagist, under rockett/sitemap. 🙂

Awesome, thanks Mike! 🙂

 

Share this post


Link to post
Share on other sites

@Mike Rockett

Sure, let me know exactly what you need me to do. Here is the field settings as copied from phpMyAdmin, in case there is something incorrect there:

{"description":"The Open Graph Image is used when sharing the page to social media services like Facebook and Twitter. Upload images that are **1200 x 630 pixels** for the best display on high resolution devices. At minimum, use images that are **600 x 315 pixels**. Be sure to include a description to be used as the alt tag.","textformatters":["TextformatterEntities","TextformatterStripTags"],"extensions":"jpg jpeg png","maxFiles":1,"outputFormat":0,"defaultValuePage":0,"useTags":0,"inputfieldClass":"InputfieldImage","collapsed":2,"descriptionRows":1,"gridMode":"list","focusMode":"on","resizeServer":0,"clientQuality":90,"overwrite":1,"maxWidth":1200,"minWidth":600,"minHeight":315,"tags":"meta images","icon":"tag","fileSchema":6,"otherField":"License","otherFieldSettings":"{\"cf_textformatter\":{\"license\":\"\"},\"cf_label\":{\"cf_label__license\":\"\"}}"}

Share this post


Link to post
Share on other sites

@Lance O.

Looks like it could well be a case sensitivity issue with the license field, where yours is using an upper case "L", it is actually expecting it in lowercase. Are you able to rename the field and try again? Whether or not that fixes it, I'll need to push an update that converts the casing appropriately.

Share this post


Link to post
Share on other sites

Hi @Mike Rockett – I'm back with the endless requests 🙂

How do you feel about supporting WireCache in MarkupSitemap, possibly as an alternative to (if not instead) MarkupCache? The thing is that due to hosting-related reasons caching in the database would be easier for me, while current MarkupCache implementation is slightly problematic.

I could send you a PR (or merge request, as you're using GitLab) in case you're interested.

  • Like 1

Share this post


Link to post
Share on other sites

Sorry @Mike Rockett – got caught up with other stuff (surprise) and forgot about this 🙂

I've just sent a merge request for WireCache support. It's an alternative to existing MarkupCache cache method, configurable via module settings. I've also made cache TTL (expire time) configurable: https://gitlab.com/rockettpw/seo/markup-sitemap/merge_requests/1.

Let me know what you think 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Mike Rockett!

I'm wondering if there's some way to add support for URL segments in the module. Any chance you might've figured this out already? 🙂

Basically in my use case there are pages that list items below them, yet those items actually live outside of the publicly viewable page tree. It's a no-brainer that they wont work right out of the box, but what I'm wondering is if we could somehow – hook or some template setting or something – inform MarkupSitemap of these "non-pages", and add them to the sitemap.

I had a quick look at the codebase, and I'm wondering if this could be achieved by an optional hook in MarkupSitemap::addPages, perhaps by passing $page and $url to a hookable method after calling $this->urlSet->addUrl($url)? Seems that this way I could add a custom round of iteration and also add those URL segments as new URLs to the URL set 🙂

  • Like 3

Share this post


Link to post
Share on other sites

Another related feature that I've thought about often is a hook for adding custom resources. The main use case would probably be videos tied to specific pages. As there is no agreed-upon way of uploading videos in ProcessWire, the module can't know what is a video and what isn't. Hooks would be perfect here.

Share this post


Link to post
Share on other sites

Hey @teppo and @d'Hinnisdaël – both very good ideas indeed. I'm happy to implement both hooks, the only problem is that this time of year is super busy for me, so I won't be able to get to it straight away. If it's something you're looking for in the immediate-term, please feel free to pop me a merge request or two. In the meantime, I'll open up an issue on the repo. 🙂

  • Like 2

Share this post


Link to post
Share on other sites

Hey @Mike Rockett. I'd be happy to try, if you're busy. I've got a need for this in one of my current projects anyway 🙂

Share this post


Link to post
Share on other sites

@Mike Rockett @teppo I just stumbled upon a local fork to the module I made some time ago that adds that functionality (additional URLs per page, added via a hook). I'll whip it into shape and create a merge request in case that provides useful or as a starting point. It's working quite well locally, just have to fork from the current state and add some docblocks.

Share this post


Link to post
Share on other sites

@Mike Rockett @teppo I created a merge request on GitLab. Happy to get some input on that. It includes an example implementation and an updated readme section on dynamic URL segments.

One thing that I couldn't figure out is creating alternate-language URLs inside the hook. The LanguagePageNames module doesn't create the hooks for Page->localHttpUrl() if the requested page results in a 404 error (which it always does when generating the Sitemap since that's what triggers it). That's why the Sitemap module manually adds those hooks when initializing. However, even when the module has been initialized and the hooks should have been added by that point, localHttpUrl() is not available on any Page object inside the hook.

I worked around that in my previous project by doing the same as the Sitemap module and adding the localUrl methods manually. It's however far from an ideal solution to have to add all that boilerplate.

Any ideas?

wire()->addHookAfter('MarkupSitemap::getAdditionalPageUrls', function ($event) {
    /* get arguments */

    static $hooksAdded = false;
    if (!$hooksAdded) {
        foreach (['localUrl', 'localHttpUrl', 'localName'] as $pageHook) {
            $pageHookFunction = 'hookPage' . ucfirst($pageHook);
            wire()->addHook("Page::{$pageHook}", null, function ($event) use ($pageHookFunction) {
                wire('modules')->LanguageSupportPageNames->{$pageHookFunction}($event);
            });
        }
    }
    $hooksAdded = true;

	/* add URLs */
});

I started working on the video element feature, but that's not as straightforward as I thought.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By NehaPillai
      Hello Everyone, I was trying to update SEO meta title, description and meta keywords for my website in Process Wire CMS but it saving in the backend but it is not reflecting on my website, Please help me regarding this error. Please find below attached screen shot for your ref. TIA.


    • By stanoliver
      My aim is to output a very basic xml document which should be styled with a few css-styles.
      <?xml version = "1.0"?> <contact-info> <name>Donal Duck</name> <company>Superducks</company> <phone>(011) 123-4567</phone> </contact-info> How do I implement it with processwire?
    • By franciccio-ITALIANO
      Hi, we can choose the "headline" and "title" and "summery" in panel page of processwire, but we can't write the "metadecriptions" and "tags".
       I can write mdescropt and tags in templates, but I've same templates for many articles... so, how I can change mdescription and tags?

      Thanks...
    • By Leftfield
      Hi All 🙂

      How to append canonical URL to head from certain templates?

      Thanks!!!
    • By Marco Angeli
      Hi there,
      I added a ssl certificate to my site and I'd like to redirect every single http url to its new https version
      So I added this code in the .htacces file, after the RewriteEngine On :
      Redirect 301 /about https://www.mysite.it/about
      Unfortunately this is now working: I get the "too many redirects" error.
      The following code works, but it's a bulk redirection to the home page, something I don't want for SEO reasons (https://moz.com/blog/save-your-website-with-redirects😞
      RewriteCond %{HTTP_HOST} mysite\.it [NC]
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://www.mysite.it/$1 [R,L]
      Any suggestions?
×
×
  • Create New...