Ad
Django: How To Add Meta Tags To Multiple Pages?
Here is a link for a similar question: Django: How can I add meta tags for social media?
This question only addresses how to add meta tags if there is only child class, now if there's multiple children that contain the
{% block extra_head_tags %}
<meta .../>
{% endblock %}
how would I implement this?
Here is a sample structure:
- Base UI.html (contains {% block extra_head_tags %}{% endblock %} )
- Child1.html(contains
{% block extra_head_tags %}
<meta CONTENT1/>
{% endblock %}
- Child2.html (contains
{% block extra_head_tags %}
<meta CONTENT2/>
{% endblock %}
Ad
Answer
As the documentation on template inheritance says:
If you need to get the content of the block from the parent template, the
{{ bl>documentation on template inheritance says:
If you need to get the content of the block from the parent template, the
{{ block.super }}
variable will do the trick.You thus can implement
Child1.html
as:{% block extra_head_tags %} {{ block.super }} <meta CONTENT1/> {% endblock %}
If you thus added meta information in the "parent template", these will show up in the rendering of the "child template" as well.
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad