Can't for the life of me seem to work this one out. I have added the following to my 'base' twig's head:
<html {{ sonata_seo_html_attributes() }}>
<head {{ sonata_seo_head_attributes() }}>
{{ sonata_seo_title() }}
{{ sonata_seo_metadatas() }}
{{ sonata_seo_link_canonical() }}
{{ sonata_seo_lang_alternates() }}
Which works great, but running Facebook debug, It is telling me I need to explicitly define og:image.
og:image is missing. The og:image meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
Now I've looked through the code and on Google but can't seem to find any mention of it, but I can't believe this is just an issue I am experiencing.
I'm trying to use it from within SonataNewsBundle / Media Bundle, and my images are loaded onto the page using:
<img data-interchange="[{% path post.image, 'small' %}, (small)], [{% path post.image, 'big' %},(large)]">
I have tried adding a Meta block to News/View and putting this:
{% block meta %}
<meta property="og:image" content="{% media post.image, 'big' %}" />
{% endblock meta %}
But get this when debugging:
Object at URL 'http://www."mysite".com/news/2014/6/17/woop-just-testing'
of type 'article' is invalid because the given value
'<img alt=' for property 'og:image:url'
could not be parsed as type 'url'.
So then I tried:
{% block meta %}
<meta property="og:image" content="{% path post.image, 'big' %}" />
{% endblock meta %}
But get this instead:
Object at URL 'http://www."mysite".com/news/2014/6/17/woop-just-testing' of type
'article' is invalid because the given value
'/uploads/media/news/0001/01/thumb_3_news_big.jpeg' for property
'og:image:url' could not be parsed as type 'url'.
Any help greatly appreciated.
Doug.
Managed to sort it, possibly not the best way but works...
In config,yml I have added the complete path to the Sonata_media section:
cdn:
server:
path: http://www.--mywebsite--.com/uploads/media/
Instead of:
cdn:
server:
path: /uploads/media/
And use this to set the Meta:
{% block meta %}
<meta property="og:image" content="{% path post.image, 'big' %}" />
{% endblock meta %}
Related
I have similar issue that Wysiwyg images not moved to public cache
when I add a file or image in wysiwyg, it displays properly in editor but after saving, it doesn't display in admin nor front.
Generated markup src is incorrect/not properly replaced:
<picture id="irozi"><source srcset="{{ wysiwyg_image('22','d9ffaffc-f286-4707-bd4b-29504628acc2','wysiwyg_original','webp') }}" type="image/webp"><img src="{{ wysiwyg_image('22','0872c470-f50a-4290-8043-96ffd5e205d2','wysiwyg_original','') }}" id="icysf" alt="test picture"></picture>
my-file.csv
My field already exists (in a custom bundle) and "File applications" doesn't show in "Entity Management".
Do I need that conf? How to achieve it with a migration?
What else should I do to have a correct src for files and images?
File applications config is required if you want to display an image that is ACL protected within the application. You can set it using a migration, e.g.:
$queries->addQuery(
new UpdateEntityConfigFieldValueQuery(
'Acme\Demobundle\Entity\FancyFile',
'image',
'attachment',
'file_applications',
['default', 'commerce']
)
);
The issue might also be related to image processing. Please, check the log file for errors.
UPDATE
Also, as a WYSIWYG field has some twig placeholders it has to be rendered with the applied postprocessing.
On the storefront it should be rendered with:
{% if entity.contentStyle|length -%}
{%- apply spaceless -%}
<style type="text/css">{{ entity.contentStyle|render_content }}</style>
{%- endapply -%}
{%- endif %}
{{ entity.content|render_content }}
There are also ready-to-use layout block types: wysiwyg_style and text_with_placeholders.
On the back-office there is a macro
{% import '#OroEntityConfig/macros.html.twig' as entityConfig %}
{{ entityConfig.renderWysiwygContentPreview(entity.content)|raw }}
Where the entity.content is the field path to render.
The team will update the documentation to mention that.
Problem
Recently I added tag support for my personal blog, but I am not happy with a way that it was done.
Blog uses jekyll with github-pages, so my solution has many limitations that platform comes with.
In order to create tag javascript I created file tag/javascript/index.html with following content:
---
layout: tag
tag: javascript
---
And it in my tag layout file I have following code:
---
layout: default
---
<div class="tag-header">
posts related to <strong>{{ page.tag }}</strong>
</div>
{% for post in site.posts %}
{% if post.tags contains page.tag %}
<section class="post">
<header>
{{ post.title }}
</header>
<time>
{{ post.date | date_to_string }}
</time>
<summary>
{% if post.excerpt %}
{{ post.excerpt }}
read more
{% endif %}
</summary>
<div class="tags">
{% for tag in post.tags %}
<span>
#{{ tag }}
</span>
{% endfor %}
</div>
</section>
{% endif %}
{% endfor %}
Result is something like this posts related to javascript.
Question
How can I automate tag creation process, so it does not require manual tag file creation (tag/javascript/index.html from sample)?
Notice
I have read An easy way to support tags in a jekyll blog already, and the only working solution for github-pages was this one, which I don't like, because it puts all tags in one page.
Additionally note that I am using github-pages, so custom plugin is not an option.
You can find full sources here.
Current Jekyll (3.1.x) cannot generate tag page automatically. You need to use a custom plugin. But you don't want to.
Why ? It's not so difficult to change deployment process on github pages.
You can store you code in master and you generated page in gh-pages. This answer will give your more information on how to do it.
I'm wanting to use Jekyll as a CMS essentially, so I would like to take the content from a post and display it in a specific area of my website.
{% for post in site.posts %}
{{ post.content }}
{% endfor %}
This displays all of the content from all of the posts, however I'd like to take content from one post at a time. I'm fairly new to Jekyll, so I'm not sure if i'm supposed to add YAML front matter into my posts and target them with a "for post in site with title_____" post.content" of sorts.
Thank you!!
{% assign thepost = site.posts | where:"slug","post_slug" %}
{% for post in thepost %}
{{ post.content }}
{% endfor %}
And on the post;
slug: post_slug
I figured it out, sorry I posted prematurely.
The answer is add a category to your post with YAML front matter and then in your include file use:
{% for post in site.categories.CATEGORYNAMEHERE %}
{{ post.content }}
{% endfor %}
I'd like to conditionally import a LESS file inside a {% compress css %} block like this:
{% compress css %}
<link href="{{ STATIC_URL }}common/css/style.css" media="screen" rel="stylesheet" type="text/css" />
{% ifequal app "custom" %}
<link href="{{STATIC_URL}}custom/less/style.less" rel="stylesheet" type="text/less">
{% endifequal %}
{% endcompress %}
I'm using offline compressions and getting an OfflineGenerationError, which makes sense, I just don't know how to go about fixing it.
I have a couple ideas:
move the logic of the import into a view and server one html file for the include and one without
move the logic into css (if/how this is possible)
provide a conditional include, which compresses the LESS file
remove compress and compile the LESS file to CSS, then the above code should work
Thanks,
Aleck
Have you remembered to set the COMPRESS_OFFLINE_CONTEXT setting, as documented here?
This is "the context to be used by the compress management command when rendering the contents of {% compress %} template tags and saving the result in the offline cache".
Since you're accessing the app context variable it could be what you need.
I'm new to jekyll and am working on building my site.
I have a "posts" layout where I'd like to have all the tags associated with the post appear in the left column. The problem I'm running into is that using {{ page.tags }} returns a list of tags that are not comma-separated and looks messy. See here for an example.
The html code for the layout page is:
<div class="span3">
</br>
<img src="{{ page.root }}assets/img/glyphicons_045_calendar.png" /> {{ page.date | > date: "%d %B %Y" }}
</br>
<img src="{{ page.root }}assets/img/glyphicons_066_tags.png" /> {{ page.tags }}
</div>
<div class="span9">
<h1> {{ page.title }} </h1>
{{ content }}
</div>
Any advice on how to (a) get the tags list to be comma-separated and (b) wrap around so it stays within the left column? Thanks!
You might try to put them inside a <p> tag so they can wrap around.
To have them comma-separated, you can follow the jekyll docs and use:
{{ page.tags | array_to_sentence_string }} => foo, bar, and baz
As is said in the Jekyll wiki.
For more precise control over what you can do with tags use the for operator:
<ul>
{% for tag in page.tags %}
<li> {{tag}} </li>
{% endfor %}
</ul>
This example is taken verbatim from somewhere. There are also more control structures to choose from.