Ajout d'un sitemap avec gestion des cours et des pages statiques, intégration d'une vue pour robots.txt, et mise à jour des modèles avec les URLs absolues pour améliorer le SEO.
This commit is contained in:
parent
e77ea7e20e
commit
cab7c07433
5 changed files with 62 additions and 1 deletions
29
devart/sitemap.py
Normal file
29
devart/sitemap.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from django.contrib import sitemaps
|
||||
from django.urls import reverse
|
||||
|
||||
# --- IMPORTS DEPUIS TES DIFFÉRENTES FEATURES ---
|
||||
from courses.models import Course
|
||||
from users.models import Profile
|
||||
|
||||
# --- SITEMAP : LES Cours ---
|
||||
class CourseSitemap(sitemaps.Sitemap):
|
||||
changefreq = "weekly"
|
||||
priority = 0.9
|
||||
|
||||
def items(self):
|
||||
return Course.objects.filter(enable=True) # Exemple de filtre
|
||||
|
||||
def location(self, item):
|
||||
# Assure-toi que ton modèle Course a bien une méthode get_absolute_url
|
||||
return item.get_absolute_url()
|
||||
|
||||
# --- SITEMAP : PAGES STATIQUES ---
|
||||
class StaticViewSitemap(sitemaps.Sitemap):
|
||||
priority = 0.5
|
||||
changefreq = "monthly"
|
||||
|
||||
def items(self):
|
||||
return ["home"] # Les noms de tes URLs
|
||||
|
||||
def location(self, item):
|
||||
return "https://partirdezero.com"
|
||||
Loading…
Add table
Add a link
Reference in a new issue