How to share `_output.yml` among blodwon posts when `blogdown.new_bundle` is TRUE?

Before blogdown 0.20, I placed _output.yml under content/post so that all the posts share the output options.

However, since blogdown 0.20, my posts do not share the _output.yml because the default value of the blogdown.new_bundle option become TRUE, and each posts are nested in individual subdirectories under post.
I love the change, but I also want to keep sharing the _output.yml among posts.
Is there any way?

Hi,

I did not even know this was a feature. That you could put _output.yaml in content/post to share options. It was a nice side effect of how rmarkdown is working. With bundle it will indeed not work, as with any project folder where you would store Rmd files in subfolders.

However, there is a way to precise this at the doc level. Have you tried setting

output_yaml: "../_output.yaml"

in the header of your posts ? It is not the same but I think it should work as it is a way to pass a specific _output.yaml (or other name) to rmarkdown::render

For supporting the old way you used with Hugo Page bundles, which the blogdown.new_bundle is about, I think it would require some special handling in blogdown. Like an option to set in .Rprofile to indicate where this file would be, or looking for a _output.yaml file in the parent folder if bundles are used but it would then put a rmarkdown logic inside blogdown itself.

Maybe setting this field in the header of all post is easy enough to do ?

I let your try and come back with feedback ! thanks !

1 Like

Oh and I think you could also use _site.yml and the output field to pass this type of option.
The file is always at the root of the project so I think it would work no matter the bundles or not.

This is also a side effect of how rmarkdown is working for website when this files is taken into account to find options for a format. But it also set a site name and an output dir so it may have undesired side effects when used with blogdown - I should try that... Interaction between all the stack is always tricky !

1 Like

Thanks. Unfortunately, neither output_yaml parameter of _site.yml work as far as I tried.
I'll try dig the problem.
If _site.yml works, that sounds the best solution.

:thinking: I tried setting output_yaml field in a post header and it worked as expected.

I have this in the YAML header

---
title: A test 3
author: ~
date: '2020-10-26'
slug: a-test-3
categories: []
tags: []
output_yaml: ../_output.yaml
---

and _output.yaml in the root post folder

> fs::dir_tree("content/post", recurse = FALSE)
content/post
+-- 2015-07-23-lorem-ipsum.md
+-- 2015-07-23-r-rmarkdown
+-- 2016-02-14-hello-markdown.md
+-- 2020-10-26-a-test-2.html
+-- 2020-10-26-a-test-2.Rmd
+-- 2020-10-26-a-test-3
+-- 2020-10-26-a-test-5
+-- 2020-10-26-a-test.md
+-- 2020-10-26-adding-a-new-post
\-- _output.yaml

The file will be found when knitting the document with rmarkdown::render (so clicking the Knit button or asking to rebuild the Rmd to Html)

And BTW _site.yml won't work with blogdown because it will also consider the Rmd root dir as the directory where _site.yml is look for. So no side effect as I thought earlier. Sorry for misleading you.

Thanks! I was using wrong path for _output.yaml.
Now I see it works.

_site.yml won't work with blogdown

I wish we have some alternative way...
I'm sure I will forget to add output_yaml: ../_output.yml occasionally.

Thanks anyway!

1 Like

You should open an issue then as a feature request to have a way to pass option into html_page format when using blogdown. That way it it will be in the backlog and can be discussed!

@cderv Defenitely! I will!

1 Like

Opened a FR issue

Another solution here is to use Hugo archetypes:

Do those not meet your needs?

2 Likes

@apreshill
Thanks! That is the best answer!!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

For reference, supported solution in blogdown is to use _output.ymlAt the root directory of the project website. This file will be taken into account by each post Rmd.

See answer in GH issue

1 Like