Closed wesleyboar closed 4 years ago
@tacc-wbomar could you check if the documentation and comment added in #628 helps clarifying the social meta tags behavior and the role of the {% block meta %}
?
Yes. The {% block meta %}
is clear*, now. Thanks!
(I will try out the "complete social meta tag rendering", like BLOG_FB
next.)
* Update: Or not. See https://github.com/nephila/djangocms-blog/issues/613#issuecomment-672182302.
Regarding BLOG_FB
, BLOG_TWITTER
, BLOG_GPLUS
/BLOG_SCHEMAORG
in settings
:
I cannot find any results in djangocms-blog
repo (searching via Github), nor (desperation) any results on the Internet (Google search). Are these future (1.2) configuration options?
Update: I stumbled upon the docs for these settings. I could not find them in the djangocms-blog
repo (I think) because that file is not in the develop
branch.
After experimenting with {% if meta %}
, I have found that it is not as reliable as expected. This may be because of my ignorance. Below is what I learned and my workarounds. Please, tell me whether any of these problems should be a new issue in this repo or another repo.
β Resolved by option "c" in new documentation.
Using {% include "meta/meta.html" %}
to render page metadata (source djangocms-page-meta
β source djangocms-meta
) did not work for me.
β¦/templates/base.html
{% load β¦ meta page_meta_tags β¦ %}
{% page_meta request.current_page as page_meta %}
<!doctype html>
<html>
<head {% meta_namespaces %}>
β¦
{% block meta %}
{% include 'djangocms_page_meta/meta.html' with meta=page_meta %}
{% endblock meta %}
I do not remember from where I copied/learned the pieces of the workaround code.
meta
β There has since been uncertainty about original solution and a new working solution.
Using {% block meta %} {% if meta %} β¦ {% endif meta %} {% endblock %}
(as documentation offers) will overwrite the block, even if I have no meta with which to overwrite the block.
Using {% if meta %} {% block meta %} β¦ {% endblock meta %} {% endif %}
, so that I overwrite the block
only if I have meta
with which to overwrite the block.
meta
is Available to Templateβ The here since been a re-explanation and a new working solution.
Using the documentation, and having both page meta and blog meta:
'meta': <meta.views.Meta object at 0x7fef6214aeb8>,
*'meta': <module 'meta' from '/usr/local/lib/python3.6/site-packages/meta/__init__.py'>,
*'meta': <module 'meta' from '/usr/local/lib/python3.6/site-packages/meta/__init__.py'>,
*Thus:
'meta': <module 'meta' β¦>
makes {% if meta %}
evaluate to true.* Data retrieved via {% debug %}
.
β¦/templates/djangocms_blog/base.html
β¦
{# A certain code block should be here, but it would cause a bug. #}
{# SEE: `./post_detail.html` #}
{# SEE: https://github.com/nephila/djangocms-blog/issues/613 #}
β¦
β¦/templates/djangocms_blog/post_detail.html
β¦
{# This conditional is irrelevant, because we will always have
`meta` in this template. This code block belongs in `./base.html`,
which would benefit from a conditional, but also cause a bug. #}
{# SEE: https://github.com/nephila/djangocms-blog/issues/613 #}
{% if meta %}
{% block meta %}
{% include "meta/meta.html" with meta=meta %}
{% endblock meta %}
{% endif %}
β¦
@tacc-wbomar this further documentation update should help clarify the proper template layout https://github.com/nephila/djangocms-blog/pull/630
djangocms-page-meta documentation is actually outdated and I will amend that as well
I also included your suggestion at point 2
Regarding point 3, blog overrides page meta on purpose as you can't have both
check updated documentation https://djangocms-blog--630.org.readthedocs.build/en/630/features/meta.html
and updated settings documentation https://djangocms-blog--630.org.readthedocs.build/en/630/autodoc/settings.html (which is not updated on RTD due to a build failure)
Thank you.
djangocms_blog/base.html
to djangocms_blog/post_detail.html
This does does change Actual Result to match Expected Result. I am not suggesting this, because I don't know. I am merely reporting what seemed to work after trial and error.
β¦
β¦
{% include "meta/meta.html" %}
β¦
β¦
djangocms_blog/base.html
This does does change Actual Result, but the Blog post has Blog page metadata.
{% include "meta/meta.html" %}
djangocms_blog/base.html
This does not change Actual Result.
{% block meta %}
{% if meta %}
{% include "meta/meta.html" %}
{% endif %}
{% endblock meta %}
This does not change Actual Result.
{% if meta %}
{% block meta %}
{% include "meta/meta.html" %}
{% endblock meta %}
{% endif %}
Is my Expected Result strange?
Perhaps, Blog page should not have page metadata. I really don't understand how users use social media, I'm just trying to get the metadata present on all the pages so I can complete implementation of our blog/news/social-media-metadata feature.
@tacc-wbomar I don't understand if you can see any metadata in the post detail view, or you can see the blog post ones and not the CMS page
If you can't see any metadata, that's of course an issue because the it's the whole point of the django-meta integration :)
I will try to replicate the issue in the https://github.com/yakky/djangocms-blog-poc repo
With the documented setup, I do not see any meta tags on the CMS's Blog page (I see meta tags on Home page, and on a Blog post page).
I think this is all the relevant info to show my setup. If helpful, I'll include bits of settings.py
.
/base.html
w/ "If & Block" Meta Inclusiontemplates/djangocms_blog/base.html
{% if meta %}
{% block meta %}
{% include "meta/meta.html" with meta=meta %}
{% endblock meta %}
{% endif %}
_The templates/djangocms_blog/post_detail.html
has no meta inclusion._
/base.html
w/ Direct Meta Inclusiontemplates/djangocms_blog/base.html
{% include "meta/meta.html" with meta=meta %}
_The templates/djangocms_blog/post_detail.html
has no meta inclusion._
/post_detail.html
w/ "If & Block" Meta Inclusiontemplates/djangocms_blog/post_detail.html
{% if meta %}
{% block meta %}
{% include "meta/meta.html" with meta=meta %}
{% endblock meta %}
{% endif %}
_The templates/djangocms_blog/base.html
has no meta inclusion._
templates/base.html
{# FAQ: Conditional includes are intentionally verbose #}
{# SEE: https://confluence.tacc.utexas.edu/x/QwI9Cw #}
{% load cms_tags staticfiles sekizai_tags cache i18n %}
<!doctype html>
<html>
{% if settings.FEATURES.blog %}
{% with path="djangocms_blog_head.html" %}{% include path %}{% endwith %}
{% else %}
<head>
{% endif %}
β¦
<!-- Metadata. -->
<title>{% block title %} This is my new project home page {% endblock title %}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% if settings.FEATURES.blog %}
{% block meta %}
{% with path="djangocms_page_meta.html" %}{% include path %}{% endwith %}
{% endblock meta %}
{% endif %}
templates/djangocms_blog_head.html
{% load meta %}
<head {% meta_namespaces %}>
templates/djangocms_page_meta.html
{% load page_meta_tags %}
{% page_meta request.current_page as meta %}
{% include 'djangocms_page_meta/meta.html' %}
@tacc-wbomar the settings and a pip freeze
output would be of great help, thanks!
Okay.
settings.py
pip freeze
\
Note: The content of this file was updated to be accurate 3 minutes after sending this comment.thanks for the details I confirm I have been able to reproduce the issue
Can you try replacing in /templates/djangocms_blog/base.html
{% block meta %}
{% comment %}
This is needed if you can't add ``{% include "meta/meta.html" %}`` in the django CMS template attached to the blog
page.
If you have something like the snippet below in the main template used by the django CMS page, you don't need
this block and you can safely remove it when customizing the blog templates
...
<html>
<head>
<title>{% block title %}{% page_attribute 'title' %}{% endblock title %}</title>
{% include "meta/meta.html" %}
...
{% endcomment %}
{% if meta %}
{% include "meta/meta.html" %}
{% endif %}
{% endblock meta %}
with
{% block meta %}
{% if meta %}
{% include "meta/meta.html" %}
{% else %}
{{ block.super }}
{% endif %}
{% endblock meta %}
Yes! That works.
awesome!
i updated #630 to fix the base template
Thanks a lot for your patience and your super detailed reports!
@tacc-wbomar thanks again. Closing this via merge of #630
Description
I am confused by purpose of the
meta
block inbase.html
template code.Steps to reproduce
djangocms-meta
setup:djangocms-blog
install.djangocms-blog
app templates, that still has this code inbase.html
:djangocms-meta
app. This includes this code inbase.html
CMS template:djangocms-meta
setup:{% block meta %}
block of code frombase.html
app template (not the CMS template).djangocms-meta
setup:{% include "metaβ¦" %}
line of code frombase.html
CMS template (not the app template).Expected result
Actual result
<meta>
tags in the<head>
.<meta>
tags in the<head>
.