Recommended Posts

markup-sitemap.svg?maxAge=7200&style=fla 3.0.16+-green.svg?style=flat-squarerequires-PHP--5.6-green.svg?style=flat-s markup-sitemap.svg?style=flat-square

Docs & Download: rockettpw/markup-sitemap
Modules Directory: MarkupSitemap

MarkupSitemap is essentially an upgrade to MarkupSitemapXML by Pete. It adds multi-language support using the built-in LanguageSupportPageNames. Where multi-language pages are available, they are added to the sitemap by means of an alternate link in that page's <url>. Support for listing images in the sitemap on a page-by-page basis and using a sitemap stylesheet are also added.

Example when using the built-in multi-language profile:

<url>
    <loc>http://domain.local/about/</loc>
    <lastmod>2017-08-27T16:16:32+02:00</lastmod>
    <xhtml:link rel="alternate" hreflang="en" href="http://domain.local/en/about/"/>
    <xhtml:link rel="alternate" hreflang="de" href="http://domain.local/de/uber/"/>
    <xhtml:link rel="alternate" hreflang="fi" href="http://domain.local/fi/tietoja/"/>
</url>

It also uses a locally maintained fork of a sitemap package by Matthew Davies that assists in automating the process.

The doesn't use the same sitemap_ignore field available in MarkupSitemapXML. Rather, it renders sitemap options fields in a Page's Settings tab. One of the fields is for excluding a Page from the sitemap, and another is for excluding its children. You can assign which templates get these config fields in the module's configuration (much like you would with MarkupSEO).

Note that the two exclusion options are mutually exclusive at this point as there may be cases where you don't want to show a parent page, but only its children. Whilst unorthodox, I'm leaving the flexibility there. (The home page cannot be excluded from the sitemap, so the applicable exclusion fields won't be available there.)

As of December 2017, you can also exclude templates from sitemap access altogether, whilst retaining their settings if previously configured.

Sitemap also allows you to include images for each page at the template level, and you can disable image output at the page level.

The module allows you to set the priority on a per-page basis (it's optional and will not be included if not set).

Lastly, a stylesheet option has also been added. You can use the default one (enabled by default), or set your own.

Note that if the module is uninstalled, any saved data on a per-page basis is removed. The same thing happens for a specific page when it is deleted after having been trashed.

pwtalk-01.thumb.jpeg.a239282a9414e4c1882e7f8d787f4a4b.jpeg  pwtalk-02.jpeg.e0cdee14590b52c7d404f05bb9e48f21.jpeg  pwtalk-03.thumb.jpeg.9956b756b9e2aea59b6239e55bee0f4f.jpeg

  • Like 15
  • Thanks 1

Share this post


Link to post
Share on other sites

Bumped to 0.1.1-beta

  • Added image support:
    • You can now specify fields in module config that should be included when rendering the sitemap. Simply choose one or more image fields from the list, and any Page that uses those fields will have their images listed in the sitemap. If a description is present, it will be used as the image caption.
    • Also supports ImageExtra. To add specific details to your sitemap's image entries, use ImageExtra to add the meta fields accordingly:
      • Add a license field to set a license for the image (it must be a URL, or it won't be included)
      • Add a title, if needed
      • Add geo, location, or geolocation if you'd like to specify the geo-location of your images
  • The template field in ModuleConfig was changed from includeTemplates to sitemap_include_templates.
  • The ModuleConfig fields now show template and field labels, and not their names.
  • Small changes to the per-Page config field descriptions and labels
  • Like 1

Share this post


Link to post
Share on other sites

Hi

Thanks for this module. I was googling tonight to find an how-to for building sitemap and see this. But I have 2 stupid questions:

  1. "Home" template is not available, is it because it's included by default?
  2. Where is the sitemap? domain.com/sitemap.xml brings me to my home page. Did I did something wrong? 

Thanks

Mel

Share this post


Link to post
Share on other sites

Hi Mel, You're most welcome.

1 hour ago, mel47 said:

"Home" template is not available, is it because it's included by default?

The list on the configuration page defines templates which get the sitemap_ignore_page and sitemap_ignore_children fields. As the home page should not be ignored, the home template does not get the fields (the module would be pretty much useless otherwise). The presentation of the sitemap works out of the box without any configuration.

Edit: I think the module config should be a little clearer with the explanation. I will sort that out now.

1 hour ago, mel47 said:

Where is the sitemap? domain.com/sitemap.xml brings me to my home page. Did I did something wrong?

The sitemap should be working at that URI. If you're looking for a simple sitemap, maybe use MarkupSitemapXML and see if it renders. If it does, then it means I've done something wrong with my module, which is based on that one.

:)

Share this post


Link to post
Share on other sites

Bumped to 0.1.2-beta

  • Fixed descriptions to better explain the purpose of the fields added to templates.
    If additional non-related fields are ever added, these descriptions will be amended accordingly.
     
  • Removes sitemap cache on module-save.
    This is already done when pages are saved, unless the option in MarkupCache's config dictates otherwise.
  • Like 2

Share this post


Link to post
Share on other sites

Thanks for clarification.

To be honest, I already tried MarkupSitemapXML before this module. I was unable to see sitemap in any of them, so I guess it's my config who failed. :(

Share this post


Link to post
Share on other sites
2 hours ago, mel47 said:

Thanks for clarification.

To be honest, I already tried MarkupSitemapXML before this module. I was unable to see sitemap in any of them, so I guess it's my config who failed. :(

You're welcome.

Are you actually redirected to your home page, or does it not redirect but does show the home page?

Share this post


Link to post
Share on other sites

Solved. Found why. Url segments was activated on home template.

Thanks!

Share this post


Link to post
Share on other sites
12 hours ago, mel47 said:

Solved. Found why. Url segments was activated on home template.

Thanks!

Ah, of course. Url segments is something that can't be supported because of how they're created... No easy way to keep track of them.

  • Like 2

Share this post


Link to post
Share on other sites

Hi Mike, wonderful module for languages and image integration!
But what can i do to fix this case?

<url>
<loc>http://www.xxx.de/</loc>
<lastmod>2017-09-10T00:03:12+02:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://www.xxx.de/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://www.xxx.de/en/"/>
</url>


Unbenannt.thumb.PNG.05e4315eaab06214e47780e351eef0e9.PNG

Share this post


Link to post
Share on other sites
7 hours ago, maxf5 said:

Hi Mike, wonderful module for languages and image integration!
But what can i do to fix this case?

<url>
<loc>http://www.xxx.de/</loc>
<lastmod>2017-09-10T00:03:12+02:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://www.xxx.de/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://www.xxx.de/en/"/>
</url>

@maxf5 - Glad you like it, and thanks for the post. I still need to work better multi-language support. Even at this point on the multi-lang site profile that PW ships with, the first alternate is identifcal to the main URL in terms of what they contain. Yours is a little different, and so I'd need to envisage the possibilities before working on it properly.

Share this post


Link to post
Share on other sites

@Mike Rockett There are 3 problems with the module:

1. The iso for the default language as @maxf5 mentioned.
2. Some pages are completely ignored
3. Wrong sitemap markup. Each link must have it's alternate links not just the default one.

I'm currently using the below method for a proper multi-language sitemap.

1st step
Create a php file "sitemap-xml-multilanguage.php" with the below code and add it on /site/templates/ folder.

<?php namespace ProcessWire;

if (!wire('modules')->isInstalled('LanguageSupportPageNames')) throw new WireException('Missing module: LanguageSupportPageNames');

// Exclude pages here
function selectors() {
	$selectors = array(
	'', // E.g. template!=variations
	); 
	return implode(',',$selectors);
}

function renderSitemapPage(Page $page) {
	$out = '';
	foreach (wire('languages') as $lg) {
		if (!$lg->isDefault() && !$page->{"status$lg->id"}) continue;
		$out .= "\n<url>" . 
			"\n\t<loc>" . $page->localHttpUrl($lg) . "</loc>" . 
			renderSitemapAlternateLangs($page) .
			"\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . 
			"\n</url>";
	}
	return $out;
}

function renderSitemapChildren(Page $page) { 

	$out = '';
	$newParents = new PageArray(); 
	$children = $page->children(selectors()); 
	
	foreach($children as $child) {
		$out .= renderSitemapPage($child);
		if($child->numChildren) $newParents->add($child); 
			else wire('pages')->uncache($child); 
	}

	foreach($newParents as $newParent) {
		$out .= renderSitemapChildren($newParent); 
		wire('pages')->uncache($newParent); 
	}

	return $out; 
}

function renderSitemapAlternateLangs(Page $page) {
	$out = '';
	foreach(wire('languages') as $lg) {
		if (!$lg->isDefault() && !$page->{"status$lg->id"}) continue;
		$iso = $lg->language_iso_code; // Custom text field for ISO under system's language template
		$out .=	"\n\t<xhtml:link rel=\"alternate\" hreflang=\"$iso\" href=\"".$page->localHttpUrl($lg)."\"/>";
	}
	return $out;
}

function renderSitemapXML(array $paths = array()) {

	$out = 	'<?xml version="1.0" encoding="UTF-8"?><urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">';

	array_unshift($paths, '/');

	foreach($paths as $path) {
		$page = wire('pages')->get($path); 
		if(!$page->id) continue; 
		$out .= renderSitemapPage($page);
		if($page->numChildren) $out .= renderSitemapChildren($page);
	}

	$out .= "\n</urlset>";

	return $out; 
}
header("Content-Type: text/xml");
echo renderSitemapXML();

Note: The above code if I remember correctly is based on @ryan and @kixe code.

2nd step
Add the new template "sitemap-xml-multilanguage" in PW and under URLs tab on "Should page URLs end with a slash?" select "No".

3rd step
Create a new page under "Home" with the title "sitemap.xml" by using the "sitemap-xml-multilanguage" template.

Final step
Create a text field with the name "language_iso_code" and add it under system's language template under "Setup > Templates > Show system templates? > Yes. Then on each language under "Setup > Languages" you will have to add the iso name. This is useful for the default language.

Here are the results I'm getting on http://localhost/mysite/sitemap.xml with my method:

<urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">
<url>
<loc>http://localhost/mysite/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/"/>
<lastmod>2017-09-02</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/"/>
<lastmod>2017-09-02</lastmod>
</url>
<url>
<loc>http://localhost/mysite/nea/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/"/>
<lastmod>2017-08-27</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/news/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/"/>
<lastmod>2017-08-27</lastmod>
</url>
<url>
<loc>http://localhost/mysite/parastaseis/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/"/>
<lastmod>2017-08-07</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/shows/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/"/>
<lastmod>2017-08-07</lastmod>
</url>
<url>
<loc>http://localhost/mysite/omada/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/omada/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/meet-the-team/"/>
<lastmod>2017-08-25</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/meet-the-team/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/omada/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/meet-the-team/"/>
<lastmod>2017-08-25</lastmod>
</url>
<url>
<loc>http://localhost/mysite/epikoinwnia/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/epikoinwnia/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/contact/"/>
<lastmod>2017-09-02</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/contact/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/epikoinwnia/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/contact/"/>
<lastmod>2017-09-02</lastmod>
</url>
<url>
<loc>http://localhost/mysite/nea/test-4/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-4/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-4/"/>
<lastmod>2017-08-14</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/news/test-4/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-4/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-4/"/>
<lastmod>2017-08-14</lastmod>
</url>
<url>
<loc>http://localhost/mysite/nea/test-3/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-3/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-3/"/>
<lastmod>2017-08-11</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/news/test-3/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-3/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-3/"/>
<lastmod>2017-08-11</lastmod>
</url>
<url>
<loc>http://localhost/mysite/nea/test-2/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-2/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-2/"/>
<lastmod>2017-08-11</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/news/test-2/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-2/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-2/"/>
<lastmod>2017-08-11</lastmod>
</url>
<url>
<loc>http://localhost/mysite/nea/test-1/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-1/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-1/"/>
<lastmod>2017-08-11</lastmod>
</url>
<url>
<loc>http://localhost/mysite/en/news/test-1/</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-1/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-1/"/>
<lastmod>2017-08-11</lastmod>
</url>
<url>
<loc>
http://localhost/mysite/parastaseis/test/
</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/test/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/test/"/>
<lastmod>2017-09-04</lastmod>
</url>
<url>
<loc>
http://localhost/mysite/en/shows/test/
</loc>
<xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/test/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/test/"/>
<lastmod>2017-09-04</lastmod>
</url>
</urlset>

 

and here are the results from your module:

<urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">
<url>
<loc>http://localhost/mysite/</loc>
<lastmod>2017-09-02T05:37:50+03:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/"/>
</url>
<url>
<loc>http://localhost/mysite/parastaseis/</loc>
<lastmod>2017-08-07T09:51:08+03:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/parastaseis/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/"/>
</url>
<url>
<loc>
http://localhost/mysite/parastaseis/test/
</loc>
<lastmod>2017-09-04T11:06:36+03:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/parastaseis/test/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/test/"/>
</url>
<url>
<loc>http://localhost/mysite/omada/</loc>
<lastmod>2017-08-25T20:27:09+03:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/omada/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/meet-the-team/"/>
</url>
<url>
<loc>http://localhost/mysite/epikoinwnia/</loc>
<lastmod>2017-09-02T04:10:51+03:00</lastmod>
<xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/epikoinwnia/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/contact/"/>
</url>
</urlset>

 

I hope it can help you fix your module.

  • Like 1

Share this post


Link to post
Share on other sites
Maybe one can make optional module settings for this problem.
Listing every language used on the website and a field for the ISO and a checkbox.
When checked it renders the "custom" ISO for this language.

  • Like 1

Share this post


Link to post
Share on other sites

@PWaddict - Thanks! I totally missed out on the actual requirements there. Will work on fixes based on your code soon. Note sure why some of those pages are being ignored as I didn't experience that myself... Will look into it.

@maxf5 - After fixes, the module will create a language ISO field and automatically add it to the language template.

  • Like 2

Share this post


Link to post
Share on other sites

Wishlist/request... would love to see on a per page/template basis a sitemap priority field.

When no priority is specified, Google goes 'top page - 100%', 'sub page - 80%', 'sub-sub-page - 60%'. 

In reality however, the 'sub-page' is often the parent page in the menu. The 'sub-sub-page' has the guts & glory that you want indexed with a high priority.

Google doesn't guarantee but says it will give a sub-sub-page with a priority eg of 80% a higher priority than it's root parent with a priority of 60%.

https://www.sitemaps.org/protocol.html

  • Like 2

Share this post


Link to post
Share on other sites

I'm making progress with all the necessary changes. On my dev server (not git-pushed yet), the following is complete:

  1. Languages: Multi-language is sorted. It now renders the sitemap according to Google standards, where a page's <url> is generated for each languages with alternate langs, including current. Method is not the same as above example (page-loop), but expands on the root-first-then-children process - this allows easier flexibility in terms of what we can ignore on a page by page basis.
  2. ISOs: Haven't created the separate language ISO field yet, as my my main concern is regarding names vs ISOs. If they are normally identical, then we would only need to declare a proper ISO name for the default language only when its URL matches the default root URL (ie: default URL root = site root). In this case, perhaps it would be better to simply have a module config entry for the default language only? The rationale behind this is that the language name (other than default) should be the same as the iso (for better SEO practice, I'd guess). I haven't yet bumped into a ProcessWire site that doesn't use the ISO for each language name accordingly. If I'm wrong, please point it out, and then I'll use the iso field, per the above example. Or perhaps I should simple allow the flexibility and have the ISO name fall back to the language name if not provided via a field (the default would still need one if it is root)?
  3. Image-support: Images are now picked up in all languages, given the process-change. If an image field is not specified in another language, it will fall back to the default language. Support for ImageExtra remains.

Priority: not done yet. I'll follow a basic principal with this: if the priority is set on a specific page, then it will be added. Otherwise, the tag will be left out. If this is not the correct methodology, please let me know. (cc @psy)

Note: I still need to do some testing on this...

  • Like 4

Share this post


Link to post
Share on other sites

Quick questions: Should the module -

  1. ping sitemap engines (after cache-revocation)?
  2. add /sitemap.xml to /robots.text if it exists and is not already added? (This would be done at install-time, and removed at uninstall-time.)

For anyone who may be curious about it, I don't plan on adding XSLT support. End of the day: sitemap.xml is intended for the viewsing of search engines, and not humans. If you want a visual sitemap, best to create your own. :-)

Share this post


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

Priority: not done yet. I'll follow a basic principal with this: if the priority is set on a specific page, then it will be added. Otherwise, the tag will be left out.

The docs say the tag is optional so it sounds right to me. Thanks @Mike Rockett

Share this post


Link to post
Share on other sites
17 hours ago, Mike Rockett said:

ISOs: Haven't created the separate language ISO field yet, as my my main concern is regarding names vs ISOs.

[...]

Just to add to this point, @maxf5's issue can be solved by adding a default-language name to the home page. In LanguageSupportPageNames, the default language URI is the same as it would be without a language, and so it won't show even if the name is set.

Here's the setup I'm using on the built-in language profile:

LanguageSupportPageNames

sitemap01.jpeg.88db4a516cdfe4e81e91d070450186f6.jpeg

Home Page default language name

sitemap02.jpeg.de30965b3f9cc18fa473ef1b86799ba0.jpeg

Sitemap url output

    <url>
        <loc>http://pw-modules.local/</loc>
        <lastmod>2017-09-15T15:35:15+02:00</lastmod>
        <xhtml:link rel="alternate" hreflang="en" href="http://pw-modules.local/"/>
        <xhtml:link rel="alternate" hreflang="de" href="http://pw-modules.local/de/"/>
        <xhtml:link rel="alternate" hreflang="fi" href="http://pw-modules.local/fi/"/>
        <...>
    </url>

 

  • Like 1

Share this post


Link to post
Share on other sites

@Mike Rockett nice "trick"! I don't remember seeing that option on LanguageSupportPageNames. I will definitely gonna use that. I'm currently using the language_iso_code field not only on my sitemap but also on site's navigation (hreflang) and the flag icons but I will delete it :)

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, PWaddict said:

@Mike Rockett nice "trick"! I don't remember seeing that option on LanguageSupportPageNames. I will definitely gonna use that. I'm currently using the language_iso_code field not only on my sitemap but also on site's navigation (hreflang) and the flag icons but I will delete it :)

Indeed it is - and I bumped into how it works by accident. Will be sticking to this method. v0.2 coming out shortly.

Share this post


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

Indeed it is - and I bumped into how it works by accident. Will be sticking to this method. v0.2 coming out shortly.

There is only a small "downside" if the website is already online. All links from the default language (except homepage) will change so the Page Path History module MUST be installed to avoid 404 errors from previously shared pages, google search etc. Make sure to update your README.md with all these important info.

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, PWaddict said:

There is only a small "downside" if the website is already online. All links from the default language (except homepage) will change so the Page Path History module MUST be installed to avoid 404 errors from previously shared pages, google search etc. Make sure to update your README.md with all these important info.

Now that I think about it, we do actually need a way to set the iso for sites that do not use a home page name for the default language.

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      Hi,
      just wanted to share something I came across while working on an import module for XML data from a web service. The XML I got was not huge, but still, loading around 3.5 MB of XML with 250+ large child nodes into memory at once with simplexml_load_file() and then looping over it had significant impact on performance.
      I searched for a solution and found this great article about how to parse large XML files.
      It basically explains how to utilize the native XMLReader class together with SimpleXMLElement to handle such situations in a memory efficient way.
      After implementing it I got a significant improval on perceived performance. No comparison in numbers to share here as I'm a bit short on time.
    • By chrizz
      hey there
      I guess a lot of you have already heard of the hreflang attribute which tells search engines which URL they should list on their result pages. For some of my projects I build this manually but now I am wondering if there's need to add this as a module to PW modules directory. 
      How do you deal with the hreflang thingy? Would you you be happy if you can use a module for this or do you have concerns that using a module maybe does not cover your current use cases?
      Cheers,
      Chris
       
       
       
       
    • By FrancisChung
      Hi, I have an ongoing issue with Google SEO that I can't seem to fix. Wondering if anyone has come across a similar situation?

      We deployed a new version of the website using a new deployment methodology and unfortunately, the wrong robots.txt file was deployed basically telling Googlebot not to scrape the site.

      The end result is that if our target keywords are used for a (Google) search, our website is displayed on the search page with "No information is available for this page." 

      Google provides a link to fix this situation on the search listing, but so far everything I have tried in it hasn't fixed the situation.
      I was wondering if anyone has gone through this scenario and what was the steps to remedy it?
      Or perhaps it has worked and I have misunderstood how it works?

      The steps I have tried in the Google Webmaster Tool :
      Gone through all crawl errors Restored the Robots.txt file and Verified with Robots.txt tester Fetch/Fetch and Render as Google as both Desktop/Mobile, using root URL and other URLs, using Indexing Requested / Indexing Requested for URL and Linked Pages. Uploaded a new Sitemap.xml  Particularly on the Sitemap page, it says 584 submitted, 94 indexed.
       
      Would the Search Engine return "No Information available" because the page is not indexed? The pages I'm searching for are our 2 most popular keywords and entry points into site. It's also one of 2 most popular category pages.  So I'm thinking it probably isn't the case but ...

      How can I prove / disprove the category pages are being indexed?

      The site in questions is Sprachspielspass.de. The keywords to search are fingerspiele and kindergedichte.

       
    • By John W.
      SYNOPSIS
      A little guide to generating an sitemap.xml using (I believe) a script Ryan originally wrote with the addition of being able to optionally exclude child pages from being output in the sitemap.xml file.
      I was looking back on a small project today where I was using a php script to generate an xml file, I believe the original was written by Ryan. Anyway, I needed a quick fix for the script to allow me to optionally exclude children of pages from being included in the sitemap.xml output.
      OVERVIEW
      A good example of this is a site where if you visit /minutes/ a page displays a list of board meetings which includes a title,  date, description and link to download the .pdf file.
      I have a template called minutes and a template called minutes-document. The first page, minutes, when loaded via /minutes/ simply grabs all of its child pages and outputs the name, description and actual path of an uploaded .pdf file for a visitor to download.
      In my back-end I have the template MINUTES and MINUTES-DOCUMENT. Thus:


      So, basically, their employee can login, hover over minutes, click new, then create a new (child) record and name it the date of the meeting e.g. June 3rd, 2016 :

       
      ---------------------------
      OPTIONALLY EXCLUDING CHILDREN - SETUP
      Outputting the sitemap.xml and optionally excluding children that belong to a template.
      The setup of the original script is as follows:
      1. Save the file to the templates folder as sitemap.xml.php
      2. Create a template called sitemap-xml and use the sitemap.xml.php file.
      3. Create a page called sitemap.xml using the sitemap-xml template
       
      Now, with that done you will need to make only a couple of slight modifications that will allow the script to exclude children of a template from output to the sitemap.xml
      1. Create a new checkbox field and name it:   sitemap_exclude_children
      2. Add the field to a template that you want to control whether the children are included/excluded from the sitemap. In my example I added it to my "minutes" template.
      3. Next, go to a page that uses a template with the field you added above. In my case, "MINUTES"
      4. Enable the checkbox to exclude children, leave it unchecked to include children.
      For example, in my MINUTES page I enabled the checkbox and now when /sitemap.xml is loaded the children for the MINUTES do not appear in the file.

       
      A SIMPLE CONDITIONAL TO CHECK THE "sitemap_exclude_children" VALUE
      This was a pretty easy modification to an existing script, adding only one line. I just figure there may be others out there using this script with the same needs.
      I simply inserted the if condition as the first line in the function:
      function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; ... ... ...  
      THE FULL SCRIPT WITH MODIFICATION
      <?php /** * ProcessWire Template to power a sitemap.xml * * 1. Copy this file to /site/templates/sitemap-xml.php * 2. Add the new template from the admin. * Under the "URLs" section, set it to NOT use trailing slashes. * 3. Create a new page at the root level, use your sitemap-xml template * and name the page "sitemap.xml". * * Note: hidden pages (and their children) are excluded from the sitemap. * If you have hidden pages that you want to be included, you can do so * by specifying the ID or path to them in an array sent to the * renderSiteMapXML() method at the bottom of this file. For instance: * * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); * * patch to prevent pages from including children in the sitemap when a field is checked / johnwarrenllc.com * 1. create a checkbox field named sitemap_exclude_children * 2. add the field to the parent template(s) you plan to use * 3. when a new page is create with this template, checking the field will prevent its children from being included in the sitemap.xml output */ function renderSitemapPage(Page $page) { return "\n<url>" . "\n\t<loc>" . $page->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; /* Aded to exclude CHILDREN if field is checked */ $out = ''; $newParents = new PageArray(); $children = $page->children; foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; array_unshift($paths, '/'); // prepend homepage foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) { $out .= renderSitemapChildren($page); } } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); // Example: echo renderSitemapXML(array('/hidden/page/'));  
      In conclusion, I have used a couple different processwire sitemap generating modules. But for my needs, the above script is fast and easy to setup/modify.
      - Thanks