I recently set up a blog with Jekyll / GitHub Pages and it automatically provides an RSS feed.
Embedding images in the blog itself works perfectly fine, using:
{{ site.baseurl }}/...
but in the RSS feed, they are not displayed.
I also noticed that this website: https://validator.w3.org/feed/ throws quite some errors, always saying that description should not contain relative URL references: /blog/assets/images/IMG_8196.jpg.
It would be great if you had an idea on how to solve this, because absolute URLs aren't too great especially when it comes to testing on own server / localhost.
Thank you in advance!
In _config.yml, set url and baseurl, if needed.
Any link or resource in your feed.xml must be pointing to an absolute url. This file is consumed my tools that only knows where to find things with absolute urls.
{{ site.url }}{{ site.baseurl }}/myPath/myFile.html
This can also be done with the new absolute_url filter
{{ "myPath/myFile.html" | absolute_url }}
And this is true for links, images, css, js, and so on.
Related
I am having great difficulties getting an image resized using Twig/Timber in Wordpress, here is my code - is there something I am missing?
<img src="{{ theme.path ~ '/images/dog.jpg' | resize(250) }}"> it just outputs wordpress.local/wp-content/themes/custom-theme/images/dog.jpg instead of wordpress.local/wp-content/themes/custom-theme/images/dog-250x0.jpg
Any suggestions appreciated!
Your image doesn't part of WordPress theme, I mean, it is but it's not been handled by WordPress Media Library using wp_handle_upload or similar approach.
Timber documentation says
All of these filters [* - resize, letterbox] are written specifically to interact with WordPress’s image API. So don’t worry, no weird TimThumb stuff going on—this is all using WordPress’s internal image sizing stuff.
That mean your images need to be uploaded by WordPress itself with all picture metadata - not just present inside your theme or even uploads directory.
We are creating a service which hosts videos. Users upload videos to our website, and we provide embed codes for playback on their websites.
We have a number of users currently using Wordpress, so we figured we would create an oEmbed service to let users easily copy/paste links into their posts.
We followed a tutorial, and and registered the following provider in wordpress via wp_oembed_add_provider in functions.php
wp_oembed_add_provider('https://vectorly.io/*', 'https://vectorly.io/wordpress/embed');
We set up an oEmbed service endpoint (https://vectorly.io/wordpress/embed?url=....), which returns the following json
{
"version":"1.0",
"type":"video",
"provider_name":"Vectorly",
"provider_url":"https://vectorly.io/",
"width":"600",
"height":"340",
"thumbnail_width":"600",
"thumbnail_height":"340",
"thumbnail_url":"https://s3-us-west-2.amazonaws.com/m.cdpn.io/screenshot-coming-soon-small.png",
"title":"NVP DemoDay - Vectorly",
"html":"<iframe src=\"https://api.vectorly.io/embed/demo/ba37b243-46c4-4f60-9a12-f6885b95c661\" width=\"600\" height=\"340\" frameborder=\"0\" allowfullscreen />"
}
Embedly seems to validate the output
Copying and pasting one of our links (https://vectorly.io/watch/ba37b243-46c4-4f60-9a12-f6885b95c661) into the Wordpress post editor does seem to successfully grab the oembed details
But the embed content editor block doesn't show a preview of the video
The actual published post looks fine though
It seems that the preview block is loading the iframe properly, but is just setting the width and height as 0 during the preview.
Looking at other non-whitelisted oembed providers, this issue doesn't seem to come up, so I think I'm doing something wrong, but I can't figure out for the life of me what it is.
Mucking around in various Wordpress files, I think that other oEmbed links (even from non-whitelisted 3rd parties) are doing something to trigger sizing of the preview Iframe in Javascript.
Any insight on this would be appreciated. Otherwise, we'll just forego oEmbed and stick with vanilla html embed codes
In case anyone else stumbles on this issue in the future:
You need to provide iframe close tags when you send oembed responses to wordpress
I.E. The following does not work
<iframe src="..." />
The following does work
<iframe src="..." ></iframe>
Adding a figure tag improves the result. See the fixed oEmbed output from our server
{
"version":"1.0",
"type":"video",
"provider_name":"Vectorly",
"provider_url":"https://vectorly.io/",
"width":"600",
"height":"338",
"thumbnail_width":"600",
"thumbnail_height":"338",
"thumbnail_url":"https://s3-us-west-2.amazonaws.com/vv-raw-videos/ba37b243-46c4-4f60-9a12-f6885b95c661.png",
"title":"NVP DemoDay - Vectorly",
"html":"<figure><iframe src=\"https://api.vectorly.io/embed/demo/ba37b243-46c4-4f60-9a12-f6885b95c661\" width=\"600\" height=\"338\" frameborder=\"0\" allowfullscreen ></iframe></figure>"
}
there.
Here's my config.yaml:
# Permalinks
permalink: pretty
relative_permalinks: true
# Setup
title: Tom Critchlow Title
tagline: My Github Site
url: http://tomcritchlow.com
paginate: 1
baseurl: /
author:
name: Tom Critchlow
url: https://twitter.com/tomcritchlow
email: tjcritchlow#gmail.com
collections:
- poetry:
output: true
And here's my folder structure:
-config.yaml
-index.html
-archive.md
_layouts
_poetry
_posts
Yet on my archive page when I do this:
{% for poem in site.poetry %}
hello world
{% endfor %}
Nothing happens... I'm also struggling to render anything in my poetry collection.
You can see the github repo here:
https://github.com/tomcritchlow/tomcritchlow.github.io
What am I doing wrong? How do you get collections working on Github pages? I'm totally new to github. Thanks.
You had config.yaml instead of _config.yaml
Looking at you github repository gave me some ideas about your problems.
First, answering to your question, your config.yaml file MUST be named _config.yml if you want Jekyll to take it into account.
But, there is a lot of other issues all over you site (empty _layouts/default.html, no _layouts/page.html, _layouts/blog.html as no front matter, baseurl/ set to / instead of "",...).
I really think it's better to work on an new clean version and copy you content to it.
gem update
make a new working folder eg: mkdir newjekyll
go to it
jekyll new .
copy your content to your new jekyll including your collection
jekyll serve
all will be ok on 127.0.0.1:4000/
I'm looking to create a dynamic rel="canonical" tag in my application which pulls in the current URL but want to ensure any query parameters are removed. E.g http://www.example.com/test/?page=2 should have the canonical as http://www.example.com/test/, therefore {{ app.request.uri }} doesn't work as this pulls in ?page=2 as well.
Does anyone know how to pull in the absolute path of a page without the query parameters?
This will work,
{{ url(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) }}
I just tried to dump baseUrl and can confirm that it does not work.
However, this works:
{{ app.request.getSchemeAndHttpHost ~ app.request.baseUrl ~ app.request.pathInfo }}
I know, it's not pretty but it does the job :)
I've got a script to post some data to wordpress using xmlrpc.
If I use a simple string for the body like "This is a test" it works fine.
However, if it has any HTML formatting in it, it gets horribly mangled when trying to add the post.
How do I post html content to wordpress with xmlrpc?
Here's a plugin that fixes a problem with some versions of an xml library that strips html: Plugin – LibXML2 Fix | Joseph Scott