Top-level country domains and multiple sitemap.xml files - how to create?

Permalink
Hi There,

We have a site that uses the same content for both New Zealand and Australia and have the site accepting incoming requests from both domains - i.e. company.co.nz and company.com.au

The question we have is how we get c5 to generate and maintain two sitemap.xml files - one for each domain?

We currently have the sitemap.xml files in separate folders and have used Google's Web Master tools to tell Google that the Australian sitemap is in at company.com.au/sitemap-oz/sitemap.xml - and the same for the New Zealand domain. But this requires us to manually generate the xml files (from each domain) then move the xml file into the right folder.

Is there a way to tell c5 about each sitemap.xml directory and have c5 maintain the files automatically?

Any help would be much appreciated.

Cheers

Ben

 
cmscss replied on at Permalink Reply
OK, so have found the /concrete/jobs folder and have created another job using this tutorial:http://www.concrete5.org/documentation/developers/system/jobs/...

But am having trouble with the syntax of the job itself.

I need to change this for the home page:
$home .= "<url>\n";
$home .= "<loc>". BASE_URL.DIR_REL."</loc>\n";


to something like this:
$home .= "<url>\n";
$home .= "<loc>". http://www.domain.com.au."</loc>\n";


But it doesn't seem to work - does anyone know how to hard-code the domain into these files?

Cheers

Ben
cmscss replied on at Permalink Reply
OK, this works for $home on line 38:
$home .= "<loc>". "http://www.domain.com.au"."</loc>\n";


But am having trouble with the $node variable on line 98 which currently has this:
$node .= "<loc>" . $cPath . "</loc>\n";


The $cPath variable is defined on line 80 as this:
$cPath = $ni->getCollectionURL($c);


Is there a way to define $cPath as something like:
$cPath = $ni->"http://www.domain.com.au"->getCollectionURL($c);


As you can see, I'm grabbing at straws!
cmscss replied on at Permalink Best Answer Reply
OK, this is for my future reference and incase other designers face the same issue.

This How-To also assumes you have concrete5 accepting connections from multiple domains. I used this add-on and did it this way:http://www.concrete5.org/marketplace/addons/multi-url-site/document...

I have two sitemap.xml files in directories - one for each country's top level domain:
/sitemap-oz/sitemap.xml
/sitemap-nz/sitemap.xml


Make sure both files are writable by the webserver.

Create your own sitemap job files by duplicating the current generate_sitemap.php job from: /concrete/jobs To: /jobs.

When you duplicate the file, change the name to something easy to identify like "generate_sitemap_oz.php" or "generate_sitemap_nz.php" or whatever you country domains are.

Duplicate and rename for as many country domains you need.

Ensure you do the correct camel case version of the name and description in the actual files as described here:
http://www.concrete5.org/documentation/developers/system/jobs/...

Once you've duplicated the job files and set the names up correctly, you can start manipulating the output.

To ensure the file gets written to the right country directory, change line 23 to your country directory. e.g.:
$xmlFile = DIR_BASE.'/sitemap-oz/sitemap.xml';


To get the home page working (the very first entry in sitemap.xml)

Change line 38 to this:
$home .= "<loc>". "http://www.company.com.au"."</loc>\n";


The to get the rest of the pages working, change line 80 to this:
$cPath = $ni->getLinkToCollection($c);


getLinkToCollection will grab the path without the domain.

Then change 93 to this which will add your specific domain to the start of the path:
$node .= "<loc>" . "http://www.company.com.au" . $cPath . "</loc>\n";


Change line 109 to the message you would like to appear after the job has been run:
return t("Oz Sitemap XML File Saved.");


Save the file and if you followed the tutorial on the c5 site (about getting jobs running) you should now see your job in the list - click "install" to install it and test it.

I also disabled the original sitemap job by clicking "Remove" next to the original job in the c5 control panel - so now only have the two country-specific jobs running.

The other part of the equation is to create a website profile for each country's domain in Google's Webmaster Tools. You then tell google where the sitemap is located for each of your domains - e.g. for the Australian domain, I've told Webmaster Tools the sitemap is located at
www.company.com.au/sitemap-oz/sitemap.xml


Hope this helps someone and if there's an easier way (that designers can understand) sing out.

Cheers

Ben