Best blog post writing practices re: image file paths and footnotes

Couple of blog questions – apologies if these are answered elsewhere!

I see on the rOpenSci blog post instructions that only the .md files should live in /content/blog. I’m wondering what people’s usual workflow for writing the blogpost is, especially with regard to images and their file paths.

After forking the roweb2 repo and working on the blog post .Rmd, should you keep that .Rmd in the /content/blog directory while you’re writing, set the knitted working directory path using
knitr::opts_knit$set(root.dir = normalizePath("../../themes/ropensci/static"))
so that images can be found correctly with /img/blog-images/<DATE-SLUG>/name-of-image.png, and then before submitting the PR remove the .Rmd from /content/blog? Or is it better to work entirely outside of the /content/blog directory, create the final .md and then change the image paths before submitting?

I’ve also noticed while serving the site locally that footnotes using the usual markdown syntax aren’t rendered correctly. Is an HTML tag is the way to go here?

1 Like

If I had decided to go with an R Markdown file, I might have also written a /content/blog/<DATE-SLUG>/.gitignore with file with an *.Rmd line, maybe also with a separate branch with a forced git add to track the .Rmd file. Also, I am not sure you should worry about how the site renders locally. A Netlify-powered CI preview is available to you once you submit the pull request to add your post. I wonder what flavor of Markdown is used for the rOpenSci website. That may be a question for @stefanie.

2 Likes

@sckott I asked @aedobbyn to post her Q here so you could weigh in, please and thanks

1 Like

Thanks for this, Will! Just writing in markdown is a viable route I hadn’t considered.

1 Like

Good question @aedobbyn

We do ignore .Rmd files with respect to what’s rendered on the website as specified in the hugo toml file here https://github.com/ropensci/roweb2/blob/master/config.toml#L7 - So even if e.g., a .Rmd file is left in the content/blog directory, it would be ignored.

You could have your .Rmd file in content/blog and then just not push it up to your remote

As for image paths I don’t have a nice solution. Anyone?

There’s some egs of references in a recent blog post https://raw.githubusercontent.com/ropensci/roweb2/master/content/blog/2018-03-16-thanking-reviewers-in-metadata.md - When rendered locally the refs for that post do work for me.

1 Like

@sckott thanks so much for the reply.

Great to know re: the gitignore! That should work fine.

For image paths, if you could use the here package inside img tags the problem would be solved! For now, though, to render the .Rmd to .md with images it looks like the best workaround is to append ../../themes/ropensci/static/ before the image path. One just has to remove that when serving the site locally.

As far as the footnotes, this was my mistake. I had a div set to display:none at the bottom of the markdown file that was wrapping a line of JavaScript to correctly render a tweet. That was messing with the look of the footnotes. Moving that div up to just under the tweet solved the issue.

1 Like