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:
commit
d6fb1baa1a
4 changed files with 5 additions and 18 deletions
|
@ -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'
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
User-agent: *
|
||||
Sitemap: /sitemap-index.xml
|
||||
Sitemap: /sitemap.xml
|
||||
Disallow: /ghost/
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
</table>
|
||||
</xsl:if>
|
||||
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) < 1">
|
||||
<p class="desc"><a href="/sitemap-index.xml" class="back-link">← Back to index</a></p>
|
||||
<p class="desc"><a href="/sitemap.xml" class="back-link">← 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">← Back to index</a></p>
|
||||
<p class="desc"><a href="/sitemap.xml" class="back-link">← 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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue