-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global sitemap, linking to each multi-site site #19
Comments
In your example, what is your I get what you're saying but also see cases where you wouldn't want it, so feel it should be a config option. What makes most sense for this though? For Trying to think of the cleanest way to tackle this. Love your input and thoughts to flesh out what is the simplest approach for the dev without making it too confusing as to which is which. I'm just in the middle of moving interstate so apologies for the delay. |
Google has some recommendations for this:
So in my mind, the sitemap index would only list the sitemaps which exist on the same domain on subpaths, and the sitemap.xml would be the same as it is now |
For the time being, I've created this myself (without any config options etc), it's simply this: <?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Spatie\ArrayToXml\ArrayToXml;
class SitemapIndexController extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(Request $request)
{
$sitemap = [
'@attributes' => [
'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
],
'sitemap' => [],
];
$sites = config('statamic.sites');
foreach ($sites['sites'] as $site) {
$sitemap['sitemap'][] = [
'loc' => url($site['url'] . 'sitemap.xml'),
];
}
$sitemap = ArrayToXml::convert($sitemap, 'sitemapindex', true, 'UTF-8');
return response($sitemap)
->header('Content-Type', 'text/xml');
}
} Which produces: <?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap.xml</loc>
</sitemap>
<sitemap>
<loc>https://www.example.com/fr/sitemap.xml</loc>
</sitemap>
</sitemapindex> |
Bug description
Currently, each site has a sitemap, e.g
/sitemap.xml
,/fr/sitemap.xml
etc.It would be great if it could generate a global file, such as
/sitemap-index.xml
at the main root, which links to each sites main sitemap. A sitemap of sitemaps if you like.Steps to reproduce
See above
Environment and versions
The text was updated successfully, but these errors were encountered: