Skip to content
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

Encode index_files as full-path #501

Closed
3 tasks
andremrsantos opened this issue Oct 26, 2020 · 4 comments
Closed
3 tasks

Encode index_files as full-path #501

andremrsantos opened this issue Oct 26, 2020 · 4 comments

Comments

@andremrsantos
Copy link

andremrsantos commented Oct 26, 2020

Hi,

I've been using blogdown on a personal lab notebook and notice after v.0.21 update that my main page, which includes the most recent post in full, the figures within index_files were not rendering. By checking their paths, I noticed they are relative to the post page.
A quick improvement is to fix these files path using encode_paths which right now just skips when detect index_files paths.

This improvement would be greatly appreciated. Thanks for everything and great job everyone!


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included 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').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.
@cderv
Copy link
Collaborator

cderv commented Oct 26, 2020

Thanks for the feedback.

Is all this happening when working on a new post ? Or is it happening for old posts ?
I would guess the former.

were not rendering.

is it in preview mode or in the build website ?

I noticed they are relative to the post page.

I believe this is due to the new default support for leaf bundle in 0.21. See the NEWS
The piece of code you mentioned

encode_paths which right now just skips when detect index_files paths
was added specifically to support leaf bundle mode in hugo.

I believe this is related to #499

you can try set options(blogdown.new_bundle = FALSE) to have the old behavior for now.

@yihui
Copy link
Member

yihui commented Oct 29, 2020

I think the problem here is, the Hugo theme displays the full content of a post on the home page, and images in the post won't be found because their paths are relative to the post instead of the home page. I can fix this issue in blogdown, but I'll do some research to see if there is a solution in Hugo first, because my fix would introduce another issue.

you can try set options(blogdown.new_bundle = FALSE) to have the old behavior for now.

Yes, that would work for new posts (but not existing posts that were created as index pages, i.e., index.Rmd or index.Rmarkdown).

@yihui yihui closed this as completed in e9535c0 Oct 29, 2020
@yihui
Copy link
Member

yihui commented Oct 29, 2020

Please the development version via

remotes::install_github('rstudio/blogdown')

Note that you need to recompile the old post once.

Thanks for the report!

yihui added a commit that referenced this issue Dec 23, 2020
… instead of using Hugo's relref, because the latter requires me to provide the input filename, which can be problematic in two ways:

1. I need to hard-code the post filename, but the filename could change: https://discourse.gohugo.io/t/29113

2. It doesn't work on a multilingual site: https://stackoverflow.com/q/65097597/559676

the shortcode blogdown/postref is basically a wrapper of .Page.Permalink, which doesn't require me to provide the post filename

the slight downside is that I have to install this simple shortcode onto all sites, and I hope users won't mind
@yihui
Copy link
Member

yihui commented Dec 23, 2020

FYI I just pushed an alternative fix to this problem, which should be more robust:

remotes::install_github('rstudio/blogdown')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants