Klimaat-Helpdesk / website

Code behind https://www.klimaathelpdesk.org/
GNU General Public License v3.0
5 stars 5 forks source link

Homepage lacks meta description #88

Closed daanreijnders closed 3 years ago

daanreijnders commented 3 years ago

The homepage currently lacks a meta description, while it's specified in the CMS at 'Helpdesk Climate Starts Here'. Is this the right place to specify it? Or should it be defined elsewhere?

The meta description that makes most sense to me is our pay-off: 'Antwoorden van wetenschappers op al je vragen over klimaatverandering'.

aquilesC commented 3 years ago

Do you mean it is missing from the html? Is this something you dare trying to fix? I'm willing to guide you if you don't know where to get started.

daanreijnders commented 3 years ago

Yup, I mean the meta description in the HTML. I'd like to give it a try. Where do you think I should start looking?

aquilesC commented 3 years ago

The templates that are responsible for rendering the HTML are in this folder

Answers to questions do have a meta name="description", so you can get some inspiration from them to copy the structure into the home page templates. The article template is this one. Note that (in case you are curious) the block extra_head is defined in the base.html.

For the home page template, you can find it here. Let me know how it goes!

daanreijnders commented 3 years ago

After looking into how Docker works for quite a bit, I think I managed to build the website locally. But I have no clue how to render something as simple as the homepage. I don't think I'll be able to test the fix myself locally without spending many hours more on this.

I think all we really need is adding some of the extra_head block into the template for the homepage. I assume the description will then be pulled from the CMS correctly. If not, we could hard-code it instead of {{ self.excerpt }}.

So what I think should be added in home_page.html is:

{% block extra_head %}
  <meta property="og:title" content="{{ self.title }}">
  <meta property="twitter:title" content="{{ self.title }}">
  {% if self.excerpt %}
    <meta name="description" content="{{ self.excerpt }}">
    <meta name="og:description" content="{{ self.excerpt }}">
    <meta name="twitter:description" content="{{ self.excerpt }}">
  {% endif %}
  <meta property="twitter:site" content="@KlimaatHelpdesk">
  <meta property="twitter:card" content="summary">
  <meta property="og:locale" content="nl_NL">
  <meta property="og:site_name" content="KlimaatHelpdesk">
{% endblock extra_head %}

Could you test this on your build?

aquilesC commented 3 years ago

@daanreijnders , too bad you didn't chime in earlier! Setting up docker is a bit complicated at the beginning and even if you succeed, you'll need a copy of the database to get started.

Although your solution is appropriate for Wagtail pages (those generated through the CMS), I have just seen that the home page itself is not defined through the CMS, but it is done by 'force' in here. So I'll just update a bit your code so it reflects this, but overall it was the kind of solution I would have proposed as well.