paulmassen / grav-plugin-seo

Manage your site’s meta tags for display in search engine results or social media networks. Create and manage json-ld microdata. Includes an easy-to-use live preview feature.
MIT License
84 stars 21 forks source link

<title> not displaying site name #7

Closed tadesign closed 7 years ago

tadesign commented 7 years ago

Hi,

Thanks for the great plugin. I only have a minor issue (and possibly a solution) Currently the tag is only displaying the words entered in the Google title field e.g. </p> <p><code><title>Google title - Words - More Words</title></code></p> <p>and not </p> <p><code><title>Google title - Words - More Words | Site Name</title></code></p> <p>To fix this I edited the partials file seo_data.html.twig so the title field line is changed from:</p> <p><code><title>{% if page.header.googletitle is defined and not empty %}{{ page.header.googletitle}}{% else %}{{ page.title }} | {{ site.title }}{% endif %}</title></code></p> <p>to</p> <p><code><title>{% if page.header.googletitle is defined and not empty %}{{ page.header.googletitle}}{% else %}{{ page.title }}{% endif %} | {{ site.title|e('html') }}</title></code></p> <p>This works for myself, I don't know if this is an issue specific to my custom theme or if my change would affect other themes.</p> <p>Many Thanks Richard</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/paulmassen"><img src="https://avatars.githubusercontent.com/u/12809352?v=4" />paulmassen</a> commented <strong> 7 years ago</strong> </div> <div class="markdown-body"> <p>Thanks Richard for your feedback.</p> <p>This behavior is actually on purpose, as if you write something in the "Google Title" Fields, it will override completely the page title, and it won't display the site name after the pipe symbol.</p> <p>Your solution works if you want indeed to display your site name, even when the title is modified manually.</p> <p>Hope it helps!</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/tadesign"><img src="https://avatars.githubusercontent.com/u/4374616?v=4" />tadesign</a> commented <strong> 7 years ago</strong> </div> <div class="markdown-body"> <p>Hi Paul,</p> <p>No problem. I'm just so used to the Title name pipe then site name format that I wasn't sure if it was an error or not. Thank you for getting back to me.</p> <p>Many Thanks Richard</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/paulmassen"><img src="https://avatars.githubusercontent.com/u/12809352?v=4" />paulmassen</a> commented <strong> 7 years ago</strong> </div> <div class="markdown-body"> <p>worth to mention that you could also use twig var for this field, something like </p> <p>My new article | {{ site.title }}</p> <p>Note that you would have to enable "process twig"</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>