mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Updated head to only output custom favicons (#11949)
closes #11932 - as per the issue, there is no need to output a <link> tag if the favicon is the default /favicon.ico, as all browsers automatically check for this - instead the favicon <link> is only output if a custom favicon has been set, telling the browser to look somewhere different to its default location - some of the tests expected 3 links in the html head, but through the favicon change there are often only 2. Co-authored-by: RenCloud <rencloud@pop-os.localdomain>
This commit is contained in:
parent
fa91c6c954
commit
58ac033b97
@ -12,7 +12,6 @@
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
|
||||
<link rel="shortcut icon" href="{{asset "favicon.ico"}}">
|
||||
<meta http-equiv="cleartype" content="on">
|
||||
|
||||
<link rel="stylesheet" href="{{asset "public/ghost.css" hasMinFile="true"}}"/>
|
||||
|
@ -125,8 +125,12 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
|
||||
if (metaData.metaDescription && metaData.metaDescription.length > 0) {
|
||||
head.push('<meta name="description" content="' + escapeExpression(metaData.metaDescription) + '" />');
|
||||
}
|
||||
|
||||
// no output in head if a publication icon is not set
|
||||
if (settingsCache.get('icon')) {
|
||||
head.push('<link rel="icon" href="' + favicon + '" type="image/' + iconType + '" />');
|
||||
}
|
||||
|
||||
head.push('<link rel="shortcut icon" href="' + favicon + '" type="image/' + iconType + '" />');
|
||||
head.push('<link rel="canonical" href="' +
|
||||
escapeExpression(metaData.canonicalUrl) + '" />');
|
||||
head.push('<meta name="referrer" content="' + referrerPolicy + '" />');
|
||||
|
@ -12,7 +12,6 @@
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
|
||||
<link rel="shortcut icon" href="{{asset "favicon.ico"}}">
|
||||
<meta http-equiv="cleartype" content="on">
|
||||
|
||||
<link rel="stylesheet" href="{{asset "public/ghost.css" hasMinFile="true"}}"/>
|
||||
|
@ -1710,7 +1710,7 @@ describe('Integration - Web - Site', function () {
|
||||
.then(function (response) {
|
||||
const $ = cheerio.load(response.body);
|
||||
response.statusCode.should.eql(200);
|
||||
$('head link')[2].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
||||
$('head link')[1].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -3410,7 +3410,7 @@ describe('Integration - Web - Site', function () {
|
||||
.then(function (response) {
|
||||
const $ = cheerio.load(response.body);
|
||||
response.statusCode.should.eql(200);
|
||||
$('head link')[2].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
||||
$('head link')[1].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -5111,7 +5111,7 @@ describe('Integration - Web - Site', function () {
|
||||
.then(function (response) {
|
||||
const $ = cheerio.load(response.body);
|
||||
response.statusCode.should.eql(200);
|
||||
$('head link')[2].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
||||
$('head link')[1].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -328,7 +328,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/page\/2\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
@ -349,7 +348,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -397,7 +395,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site SEO description" \/>/);
|
||||
@ -440,7 +437,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/about\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="all about our site" \/>/);
|
||||
@ -489,7 +485,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/about\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="referrer" content="no-referrer-when-downgrade" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="all about our site" \/>/);
|
||||
@ -545,7 +540,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
const re4 = new RegExp('"dateModified": "' + new Date(renderObject.post.updated_at).toISOString());
|
||||
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -611,7 +605,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -673,7 +666,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.not.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -724,7 +716,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.not.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -784,7 +775,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site "test" description" \/>/);
|
||||
@ -844,7 +834,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -901,7 +890,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -959,7 +947,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.not.match(/<meta name="description" /);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta property="og:description" content="This is a short post" \/>/);
|
||||
rendered.string.should.match(/<meta name="twitter:description" content="This is a short post" \/>/);
|
||||
@ -982,7 +969,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/about\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
@ -1003,7 +989,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/page\/3\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="prev" href="http:\/\/localhost:65530\/page\/2\/" \/>/);
|
||||
@ -1028,7 +1013,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/page\/2\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="prev" href="http:\/\/localhost:65530\/" \/>/);
|
||||
@ -1056,7 +1040,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/tag\/tagtitle\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="tag meta description" \/>/);
|
||||
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
|
||||
@ -1099,7 +1082,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/tag\/tagtitle\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="tag description"/);
|
||||
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
|
||||
@ -1141,7 +1123,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.not.match(/<meta name="description"/);
|
||||
rendered.string.should.not.match(/<meta property="og:description"/);
|
||||
rendered.string.should.not.match(/<meta name="twitter:description"/);
|
||||
@ -1165,7 +1146,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/tag\/tagtitle\/page\/2\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.not.match(/<meta name="description" content="tag meta description" \/>/);
|
||||
@ -1188,7 +1168,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/author\/authorname\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="Author bio"/);
|
||||
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
|
||||
@ -1228,7 +1207,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/author\/authorname1\/page\/2\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
@ -1248,7 +1226,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.9" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
|
||||
@ -1291,7 +1268,6 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.ico" type="image\/x-icon" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/featured\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
@ -1334,7 +1310,7 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/site\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="icon" href="\/site\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/site\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/site\/rss\/" \/>/);
|
||||
@ -1372,7 +1348,7 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/site\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="icon" href="\/site\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<meta name="referrer" content="origin" \/>/);
|
||||
rendered.string.should.not.match(/<meta name="description" /);
|
||||
|
||||
@ -1415,7 +1391,7 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="icon" href="\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/post\/" \/>/);
|
||||
rendered.string.should.match(/<link rel="amphtml" href="http:\/\/localhost:65530\/post\/amp\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="description" content="site description" \/>/);
|
||||
@ -1455,7 +1431,7 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="icon" href="\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
@ -1541,7 +1517,7 @@ describe('{{ghost_head}} helper', function () {
|
||||
}
|
||||
})).then(function (rendered) {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.match(/<link rel="shortcut icon" href="\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="icon" href="\/favicon.png" type="image\/png" \/>/);
|
||||
rendered.string.should.match(/<link rel="canonical" href="http:\/\/localhost:65530\/" \/>/);
|
||||
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
|
||||
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/localhost:65530\/rss\/" \/>/);
|
||||
|
Loading…
Reference in New Issue
Block a user