wagtail
wagtail copied to clipboard
default meta description value
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 }}" />
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.
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?
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.
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.
@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.
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 .. 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.
@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
@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.
![]()
@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.
@onno-timmerman @lb- taking this one up, try to close it as quickly as possible
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
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
this could cause confusion if anyone decides to customize it via seo_description
@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
Awesome @salty-ivy - I have marked it as needing a review
Fixed in #9764