New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images in Page Bundles Missing from RSS Feed #384
Comments
I think this issue belongs to Hugo; Anyway, if the actual trouble is the thumbnail, one workaround is that you use absolute URLs, e.g.
That is up to the RSS parser/reader. For example, Feedly can correct parse and show the images with relative URLs, and I know R-bloggers.com has had problems with relative URLs in RSS feeds for long. |
The thumbnail display issue has been resolved last year via https://github.com/rstudio/blog/pull/199. For the rest of issues (the |
I'm dealing with this on the theme-side, which is where I think it (currently) needs to be addressed. Unfortunately, the current behavior punishes folks who use bundled posts, because you insert images using relative links. This is easier for users, but Hugo doesn't have an easy way to turn these relative image links inside content pages into absolute urls. Here are 2 things theme developers can do:
|
Both relative and absolute URLs have their pros and cons. I prefer using relative URLs by myself whenever possible. As I said in my first reply, if the relative URLs don't work in a RSS reader (including R-bloggers), it's not necessarily the problem of the RSS feed. It could be fixed by the RSS feed reader, and it is up to the feed reader whether they are willing to deal with this problem. Feedly is one example that reads relative URLs of images and turns them into absolute URLs correctly. From a technical point of view, I think this problem is easier to address from the RSS reader's side than the feed author's side, since the RSS reader has to read XML anyway (then it can do the post-processing). It's definitely fixable from the site author's side, but (1) the solution would be hackish, and (2) every site author would have to do this on every site. If it has to be done anyway, I'd go with the first approach you mentioned. That approach is not a complete solution, though. It needs to exclude the cases of absolute URLs, i.e., if a URL is already absolute, we shouldn't prepend the permanent URL to image URLs. I added a shortcode Yet another solution is to post-process the RSS files using XML tools. This is not very different with the approach https://jdheyburn.co.uk/blog/who-goes-blogging-6-three-steps-to-improve-hugos-rss-feeds/#fix-image-rendering, but it can provide a much more general tool to deal with any RSS feeds (not limited to those generated by Hugo). This shouldn't be hard to implement. The only problem is that, again, I feel it would be much more efficient for the RSS reader to address this issue, so no authors would need to deal with this annoying problem. |
I asked a friend and he wrote some Python code to process any RSS feeds to convert relative URLs to absolute URLs: https://github.com/elisong/rssxml-linksub The code is currently deployed as a service at: https://rssxml-linksub.herokuapp.com You can pass any RSS feed to it and it will returned the processed feed, e.g., https://rssxml-linksub.herokuapp.com/api?rss=https://blog.rstudio.com/index.xml You can see, for example, the image Technically it is pretty much one regular expression: https://github.com/elisong/rssxml-linksub/blob/05aefb6/api/api.py#L38-L41 which is why I said it should be relatively easy for the RSS reader to address this issue. That said, I might spend some time on improving this approach in the future: https://jdheyburn.co.uk/blog/who-goes-blogging-6-three-steps-to-improve-hugos-rss-feeds/#fix-image-rendering His regex didn't consider the case of URLs that are already absolute. |
Version 0.1 changed the default behavior to use post bundles:
Images added to the site as resource files in this way do not show up in RSS feeds. For example, refer to: https://github.com/rstudio/blog/pull/173
The first image is referenced from the root
static
directory, and is correctly qualified:Whereas the second image is referenced in a page bundle, and is incorrect:
For certain sites, such as the rstudio blog, this issue also prevents the relative image from being correctly rendered as a thumbnail for a post.
By filing an issue to this repo, I promise that
xfun::session_info('blogdown')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/blogdown')
.The text was updated successfully, but these errors were encountered: