how Video sitemaps and video sitemap alternatives for django

Viewed 63

The sitemap framework

Django comes with a high-level sitemap-generating framework to create sitemap XML files. Overview

A sitemap is an XML file on your website that tells search-engine indexers how frequently your pages change and how “important” certain pages are in relation to other pages on your site. This information helps search engines index your site.

The Django sitemap framework automates the creation of this XML file by letting you express this information in Python code.

how use Django The sitemap framework for videos

don't work

from django.urls import path
from django.conf.urls import url 
from . import views
from django.contrib.sitemaps.views import sitemap

from .sitemaps import PostSitemap

sitemaps = {
    'posts': PostSitemap
}


app_name = 'blog'

urlpatterns = [
    path('', views.home, name='homepage'),
    path('search/', views.post_search, name='post_search'),
    path('articles/<slug:post>/', views.post_single, name='post_single'),
    path('videos', views.videos, name='videos'),
    path('video/<slug:post>/', views.post_single, name='video_single'),
    # path('category/<category>/', views.CatListView.as_view(), name='category'),
    url(r'^a/(?P<hierarchy>.+)/$', views.show_category, name='category'),
    # url(r'^(?P<slug>[\w-]+)/$', views.post_detail, name="detail"),
    path('bodyOrgans/<bodyOrgans>/', views.bodyOrgans.as_view(), name='bodyOrgans'),
    path('page/<page>/', views.page.as_view(), name='page'),
    path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='sitemap'),
    
    path('custom-sitemap.xml', views.index, {
        'sitemaps': sitemaps,
        'template_name': 'custom_sitemap.html'
    }), 

]

how make output like it

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
   <url>
     <loc>http://www.example.com/videos/some_video_landing_page.html</loc>
     <video:video>
       <video:thumbnail_loc>http://www.example.com/thumbs/123.jpg</video:thumbnail_loc>
       <video:title>Grilling steaks for summer</video:title>
       <video:description>Alkis shows you how to get perfectly done steaks every
         time</video:description>
       <video:content_loc>
          http://streamserver.example.com/video123.mp4</video:content_loc>
       <video:player_loc>
         http://www.example.com/videoplayer.php?video=123</video:player_loc>
       <video:duration>600</video:duration>
       <video:expiration_date>2021-11-05T19:20:30+08:00</video:expiration_date>
       <video:rating>4.2</video:rating>
       <video:view_count>12345</video:view_count>
       <video:publication_date>2007-11-05T19:20:30+08:00</video:publication_date>
       <video:family_friendly>yes</video:family_friendly>
       <video:restriction relationship="allow">IE GB US CA</video:restriction>
       <video:price currency="EUR">1.99</video:price>
       <video:requires_subscription>yes</video:requires_subscription>
       <video:uploader
         info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson
       </video:uploader>
       <video:live>no</video:live>
     </video:video>
   </url>
</urlset>
0 Answers
Related