Skip to content
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

Add <link rel="alternate"> to header #48

Open
kevquirk opened this issue Aug 28, 2019 · 5 comments
Open

Add <link rel="alternate"> to header #48

kevquirk opened this issue Aug 28, 2019 · 5 comments

Comments

@kevquirk
Copy link

I'm using this plugin for my site, but I was surprised to see that <link rel="alternate"> was not added to the header automatically.

Adding this to the header is trivial, but I would have expected to see this added automatically to aid in feed discovery.

Can a fix be added that automatically add the code below to the base.html.twig file?

<!-- RSS -->
<link rel="alternate" type="application/rss+xml" href="https://gravdomain.com/home.rss" />
<!-- End RSS -->
@feutl
Copy link

feutl commented Oct 28, 2019

Would love to see this as well.
Btw. even if it seems trivial, but could you tell me how this is done with the standard quark theme being used?

Thanks

@jeremycherfas
Copy link
Contributor

Yes, I too was surprised that it wasn't inserted automatically. But it is easy enough, as Kevquirk said. If you edit /user/themes/quark/templates/partials/base.html.twig to insert those three lines (or just the middle one!) somewhere between line 8 and lines 18, it should work fine.

@rzw
Copy link

rzw commented Mar 22, 2021

I'm not so sure it's that trivial. Changing base.html.twig puts it on every page, right? But if you play by Google rules it should only be on one page - the main podcast page. This is what I picked up:

Google is very strict on this, you can only have one link rel=”alternate” …> in any given page and they only want to see it on the main webpage for your podcast website, not all pages.

My fix was an extra podcast template with {% extends 'partials/audio.html.twig' %} at the top instead of base.html.twig having the rel="alternate" in there then.

@domsson
Copy link

domsson commented Mar 1, 2022

My approach to the problem @rzw brought up was to amend the base.html.twig template as follows:

{% block head %}
    {# the usual contents #}
    {% block head_content %}{% endblock %}
{% endblock %}

Which then enabled me to have a blog.html.twig which does:

{% block head_content %}
    <link rel="alternate" type="application/rss+xml" href="{{ base_url }}.rss">
{% endblock %}

However, I think an alternative (or maybe additionally), there could be some if block that checks for whether or not the page has the content header field - same condition as the plugin uses to generate the feed in the first place. Something like this (untested, just to illustrate):

{% block head_content %} {# maybe #}
    {% if page.header.content %}
        <link rel="alternate" type="application/rss+xml" href="{{ base_url }}.rss">
    {% endif %}
{% endblock %} {# maybe #}

@symgryph
Copy link

symgryph commented Feb 6, 2023

I added this to my blog theme. It seems to work nicely. I tried it with the for pay theme of typhoon theme. It worked. Thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants