Gianluca Baio
Gianluca Baio

Reputation: 41

Local build not rendering as expected (links broken)

The blogdown book suggests that local preview works using

blogdown::build_site(local=TRUE)

If I understand this correctly, this is supposed to temporarily change the config.toml file to set the baseurl to / thus overwriting whatever setting you have. When I try that, however, it doesn't really work and it keeps showing the original baseurl in the resulting public folder.

Is there a way to create a "local" version of the resulting site that would keep the links (or most of them, anyway) correct (rather than pointing to the baseurl and the online version, which works perfectly, BTW)?

I have seen some posts suggesting that some themes may not be suitable to do that as the authors may have not written the original code to point to relativeurls (I know I'm being vague here, but I think it goes to that effect), but is there a way around it?

Thanks

Upvotes: 1

Views: 103

Answers (2)

Julien Colomb
Julien Colomb

Reputation: 563

Anyway to make the "automatic redirect from site/folder to site/folder/index.html" to work?

I think uglyURLs: true is supposed to do that (not redirecting, but changing the link to the latter form.

Seems not to always work, though.

Upvotes: 0

Yihui Xie
Yihui Xie

Reputation: 30174

This should be possible with the dev version of blogdown now:

remotes::install_github('rstudio/blogdown')

Then restart R, and run:

blogdown::build_site(baseURL = '/')

This should temporarily override the baseURL setting in your config file. Similarly, you can try to build the site with relativeURLs = true:

blogdown::build_site(relativeURLs = TRUE)

Upvotes: 0

Related Questions