wagtail icon indicating copy to clipboard operation
wagtail copied to clipboard

default meta description value

Open onno-timmerman opened this issue 2 years ago • 6 comments

When you start fresh project (wagtail 4.1.1) then you get some nice default file. In your templates you will find base.html and will see that the title of the page is already filled in to the common pattern you will use for wagtail But the default meta description is empty. You can have several meta description strategies but in wagtail we have a dedicated field. Maybe this should be in the default markup then

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>
            {% block title %}
            {% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %}
            {% endblock %}
            {% block title_suffix %}
            {% wagtail_site as current_site %}
            {% if current_site and current_site.site_name %}- {{ current_site.site_name }}{% endif %}
            {% endblock %}
        </title>
        <meta name="description" content="" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />

to

<meta name="description" content="{{ page.search_description }}" />

onno-timmerman avatar Nov 14 '22 10:11 onno-timmerman

Good idea. Maybe we should have some basic logic to check the description exists (I'm not sure on the rules with meta tags with empty values though - maybe it's ok).

Here are some links to examples from other projects.

https://github.com/wagtail/guide/blob/main/apps/core/templates/base.html#L16

https://github.com/wagtail/wagtail.org/blob/main/wagtailio/templates/base.html#L8

I'll flag as a good first issue.

lb- avatar Nov 14 '22 11:11 lb-

Hello @onno-timmerman @lb- currently in the description it is showing empty so what exactly should be there(as metadata) could you provide some ideas/examples so that I could work on this issue.(being the good first issue, I would like to put in my efforts to resolve this )

I mean if it should be one liner or anything else?

AnishaSingh0118 avatar Nov 14 '22 11:11 AnishaSingh0118

Either you place page.search_description

Or maybe something basic function you can override. So a dev can say something like

def seo_description(self): return self.search_description

That way you can put any some logic in the seo_description. My guess is if you know howto then you can do that easy yourself. Although it always nice to have always same methods over your projects and makes a dev think about the options you have. Example sometimes you want to take the first words of an intro if the search_description is empty.

onno-timmerman avatar Nov 14 '22 11:11 onno-timmerman

Either you place page.search_description

Or maybe something basic function you can override. So a dev can say something like

def seo_description(self): return self.search_description

That way you can put any some logic in the seo_description. My guess is if you know howto then you can do that easy yourself. Although it always nice to have always same methods over your projects and makes a dev think about the options you have. Example sometimes you want to take the first words of an intro if the search_description is empty.

Ok, thanks for your help and support.

AnishaSingh0118 avatar Nov 14 '22 11:11 AnishaSingh0118

@onno-timmerman .. Could you suggest which one I am trying to fix is appropriate for this particular issue so that I can have a better idea towards it.

IMG_20221117_171329

IMG_20221117_171358

AnishaSingh0118 avatar Nov 17 '22 12:11 AnishaSingh0118

You can fill this in but in the default template that Wagtail deliver base.html the tag is not filled in. It would be nice that its by default there just like the title meta tag

<meta name="description" content="" />

onno-timmerman avatar Nov 17 '22 13:11 onno-timmerman

@onno-timmerman .. Could you suggest which one I am trying to fix is appropriate for this particular issue so that I can have a better idea towards it.

IMG_20221117_171329

IMG_20221117_171358

@AnishaSingh0118 it is very much possible to fix it through manual input, the issue is all about default behaviour and its customization ,

in case if you are stuck , let me know you, should first open a draft PR i will help you out through the commits

salty-ivy avatar Nov 20 '22 09:11 salty-ivy

@onno-timmerman .. Could you suggest which one I am trying to fix is appropriate for this particular issue so that I can have a better idea towards it. IMG_20221117_171329 IMG_20221117_171358

@AnishaSingh0118 it is very much possible to fix it through manual input, the issue is all about default behaviour and its customization ,

in case if you are stuck , let me know you, should first open a draft PR i will help you out through the commits

Ok, thanks for your support. I making a draft.

AnishaSingh0118 avatar Nov 20 '22 09:11 AnishaSingh0118

@onno-timmerman @lb- taking this one up, try to close it as quickly as possible

salty-ivy avatar Dec 06 '22 19:12 salty-ivy

Either you place page.search_description

Or maybe something basic function you can override. So a dev can say something like

def seo_description(self): return self.search_description

That way you can put any some logic in the seo_description. My guess is if you know howto then you can do that easy yourself. Although it always nice to have always same methods over your projects and makes a dev think about the options you have. Example sometimes you want to take the first words of an intro if the search_description is empty.

@onno-timmerman i did try to put the function, it was working pretty well but there's this conflict that meta description in the promote tab doesn't seems to update with our custom seo_description function so i think we should just put search_description

image this doesn't seems to update the admin form of the meta description in the promote tab, it only displays the text that had been entered through the form itself image this could cause confusion if anyone decides to customize it via seo_description

salty-ivy avatar Dec 07 '22 19:12 salty-ivy

@lb- i have made the PR https://github.com/wagtail/wagtail/pull/9764, kindly review at your ease and let me know for any suggestions thank you

salty-ivy avatar Dec 07 '22 19:12 salty-ivy

Awesome @salty-ivy - I have marked it as needing a review

lb- avatar Dec 07 '22 20:12 lb-

Fixed in #9764

gasman avatar Dec 08 '22 14:12 gasman