Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

blogdown - 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...