Blogdown serve_site() returns index of site, rather than site preview

blogdown

#1

I’m in the early days of learning and using blogdown, and running into an issue where serve_site() returns a blank preview, and then upon refresh, and index of my site. If I push to GitHub the site will publish on the web without issues - which I’ve been using as a “live and definitely published” preview - but I would really like to make use of the serve_site() function within RStudio so that I’m not constantly using a live site for previewing purposes.

The following is what I see when I use the “Serve Site” addin with RStudio (I receive the same results when I use blogdown::serve_site()):

When I refresh the viewer I get the following (I also get this when viewing in the browser):

Things that I’ve tried:

  • updated all the things (R, RStudio, packages, and OS)
  • restarted my computer because you never know
  • I’ve Googled this but not come up with anything actionable beyond setting relativeurls = true (which I’ve done - it’s resulted in no change)
  • a similar error seems to have occurred for Windows users here, but no solution was found
  • I’ve tried replicating the issue on my PC, but run into so many issues just trying to get blogdown and hugo to work that it’s prohibitively difficult
  • I’ve run reprex() following serve site multiple times, and it just picks up the last URL I’ve copied to my clipboard.

I’m running everything on macOS High Sierra 10.13.3

Any insights would be most appreciated!


#2

Is it possible you’re somehow not using a theme? The way hugo works is that it basically creates an index (I think they’re called lists as content type), or a single for any folder or page inside of the served folder, which makes me think you could be serving the wrong folder somehow… (or not have it configured to point to the proper combination, rather).

EDIT: the theme also exists basically in parallel to your content folder (at least for me it does)


#3

that sounds like it could be the issue, although I’m not sure how to go about fixing it. the issue is localized to RStudio, as the site itself publishes the theme.

this is the high level file structure (the not_used_sort_later folder contains all the files related to publications that I was trying to remove from the site. there are no configuration files in there.) RStudio hasn’t ever displayed the preview for this theme, which makes me wonder if it’s worth just looking for a new theme?

54%20PM


#4

Hmm, that setup looks right to me…

Have you pointed to your theme in your config?

theme = "hugo-icarus-theme"
# Comment the themesDir option if you use this theme in production
# themesDir = "../.."

which, inside of that theme folder:


#5

yep yep, the config.toml points to the academic theme:


#6

Hmm…can confirm it’s not a your-computer thing.

It’s an anchor/scrolly theme, right? Have you asked if anyone else using Academic has trouble serving locally?


#7

honestly I feel :100: knowing that it’s not something on my end - thank you for checking that out! I’ll poke around and see if anyone else using Academic is having trouble serving locally and post here if/when I find something out.


#8

I mean, if it’s a local build, there isn’t exactly another end to be on… :stuck_out_tongue_winking_eye:

Bonus thought: Have you tried serving it locally from the command line with hugo serve?


#9

fair play - although I thought I had moved/deleted/somehow or otherwise caused the issue :laughing:

serving locally from the command line is a great idea! I’ve tried it and learned that I have a bunch of PATH issues I need to fix. I’ll take a stab at that this evening/tomorrow and see if that resolves the issue.


#10

I run academic in RStudio with no problems… I had some issues in the beginning (not the same index problem as yours) and had to copy all RMD files and the static folder, burn everything to the ground and copy the files into a fresh build of the theme.

It may be worth testing whether a fresh build of the academic theme with no changes works in RStudio. That might narrow it to whether it’s s something with RStudio/blogdown vs a file or directory issue in the blog.


#11

Hi! I was able to reproduce your issue by cloning the repo (https://github.com/kierisi/jessemaegan) and running blogdown::serve_site(). I noticed that the themes/academic/ folder is empty, which explains the local issues. For local testing, can you copy the actual theme, or maybe install it using install_theme()?


#12

THIS DID IT! :tada::tada::tada:

In thinking back to when I installed the theme originally, I followed the recommendation by the theme creator to install via the browser, and now see that they also have instructions for installing via RStudio - which in retrospect I should have done in the first place.

Thank you to everyone for all of your help!


#13

3 posts were split to a new topic: Serve_site() creates index of site, rather than site preview - blogdown