0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Merge pull request #4599 from PaulAdamDavis/sitemap-index

Change sitemap root location
This commit is contained in:
John O'Nolan 2014-12-08 01:34:36 +02:00
commit d6fb1baa1a
4 changed files with 5 additions and 18 deletions

View file

@ -16,13 +16,7 @@ module.exports = function (blogApp) {
return sitemap.getSiteMapXml(type, page);
};
// Redirect normal sitemap.xml requests to sitemap-index.xml
blogApp.get('/sitemap.xml', function (req, res) {
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S});
res.redirect(301, req.baseUrl + '/sitemap-index.xml');
});
blogApp.get('/sitemap-index.xml', function (req, res) {
res.set({
'Cache-Control': 'public, max-age=' + utils.ONE_HOUR_S,
'Content-Type': 'text/xml'

View file

@ -1,3 +1,3 @@
User-agent: *
Sitemap: /sitemap-index.xml
Sitemap: /sitemap.xml
Disallow: /ghost/

View file

@ -95,7 +95,7 @@
</table>
</xsl:if>
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">
<p class="desc"><a href="/sitemap-index.xml" class="back-link">&#8592; Back to index</a></p>
<p class="desc"><a href="/sitemap.xml" class="back-link">&#8592; Back to index</a></p>
<table id="sitemap" cellpadding="3">
<thead>
<tr>
@ -135,13 +135,13 @@
</xsl:for-each>
</tbody>
</table>
<p class="desc"><a href="/sitemap-index.xml" class="back-link">&#8592; Back to index</a></p>
<p class="desc"><a href="/sitemap.xml" class="back-link">&#8592; Back to index</a></p>
</xsl:if>
</div>
<script type="text/javascript">
<![CDATA[
window.onload = function() {
var sitemapIndex = window.location.href.replace(/sitemap-.*\.xml$/, 'sitemap-index.xml'),
var sitemapIndex = window.location.href.replace(/sitemap-.*\.xml$/, 'sitemap.xml'),
links = document.querySelectorAll('.back-link'),
i;
if (links.length > 0) {

View file

@ -935,15 +935,8 @@ describe('Frontend Routing', function () {
}).catch(done);
});
it('should redirect for /sitemap.xml', function (done) {
it('should serve sitemap.xml', function (done) {
request.get('/sitemap.xml')
.expect(301)
.expect('location', /sitemap-index.xml/)
.end(doEnd(done));
});
it('should serve sitemap-index.xml', function (done) {
request.get('/sitemap-index.xml')
.expect(200)
.expect('Content-Type', 'text/xml; charset=utf-8')
.end(doEnd(done));