-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Description
I would like to request the addition of a canonical URL feature for articles and other content types in the Django Meta library. This feature would allow developers to specify a canonical URL for each article, which helps to avoid duplicate content issues and improve SEO.
Use cases
SEO Optimization: This feature will help websites that produce similar or duplicate content indicate the primary version to search engines, improving their search rankings and visibility.
Content Syndication: When content is shared across multiple platforms or websites, specifying a canonical URL will maintain the original source’s authority and prevent penalties for duplicate content.
Managing Multiple URLs: Websites with dynamic content or multiple ways to access the same resource can benefit from specifying a canonical URL to unify indexing by search engines.
Proposed solution
The proposed solution is to add a canonical_url field to the existing models in the Django Meta library. This field would allow developers to set a specific URL that represents the canonical version of an article or content. Additionally, this could be integrated into the metadata rendering in the template engine, automatically including the canonical URL in the section of the HTML.
Pass canonical_url in the _medata = {}. (As per model support)
and receive this in the head section
pass in the get_schema and received as a context in the html and passed manually
class Post(ModelMeta, SEO, HitCountMixin):
...
_metadata = {
'title': 'title',
'description': 'description', # Assuming you want to use content for the description
'image': 'get_meta_image',
}
def get_schema(self):
return {
'@context': 'https://schema.org',
'@type': 'Article',
'url': self.get_absolute_url(),
'headline': self.title,
'image': self.get_meta_image(),
'author': {
'@type': 'Person',
'name': self.get_author_name(), # Call the method
},
'datePublished': self.created_at.isoformat(),
'dateModified': self.updated_at.isoformat(),
'description': self.description, # You can adjust this as needed
'canonical': self.get_absolute_url(),
}
In base.html
{% if schema.canonical %}
{% endif %}
Additional information
Implementing this feature would align with SEO best practices and enhance the capabilities of the Django Meta library. It would also encourage more developers to adopt the library for effectively managing SEO-related metadata.