Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hugo not reading .Rmd files after using blogdown

I am working on creating a website using Github Pages and Hugo (proquestionasker.github.io). Currently, when I create project files or blog articles in RMarkdown, I have to convert them to markdown (.md) files before Hugo/Github will read them. The blogdown package seems like it would be a perfect fit for my needs, but I can't get it to work.

I have downloaded both Hugo and blogdown. My steps are currently as follows (working in the project directory as my working directory):

(in R studio)

    # Create new file in the "content/portfolio" folder
    blogdown::new_content("portfolio/new.Rmd", format = "yaml")

This creates a new .Rmd document in the folder where I'd expect. The header reads:

    ---
    date: 2016-12-15T16:02:46-08:00
    draft: true
    image: "img/portfolio/map.png"
    showonlyimage: false
    title: test
    ---

I continue to add R content to the file as I would with any R document. I save the file. At this point, I just want to test if Hugo can interpret this file before I push the changes to Github, so in R:

    # Build Site
    blogdown::build_site()

I receive the normal "site building" feedback that I expect from Hugo. When I look in the public/portfolio folder, I see a "new.Rmd". So far so good.

The problem comes with actually viewing the site. I try to preview the site the "normal" Hugo way:

    # In terminal window
    hugo server

And then launch http://localhost:1313/ in my browser window. My portfolio pieces are displayed on the home page, and all files that are .md format are displayed, but new.Rmd is not.

I thought this may be an issue because hugo server seems to still be building the site using hugo, not blogdown. So I bypassed previewing the site and went straight to committing the changes to GitHub.

The way that my site is set-up, I have the master branch (containing all of the site-building items in the 'public' folder) as a subtree of the 'sources' branch. I followed my normal process for updating (as seen below and inspired by this post) but instead of building the site using hugo, I build the site using blogdown. The process is as follows:

    # In terminal window - Adding new documents
    git add -A
    git commit -am "Adding new blogdown documents"
    git push

    # Pulling down the master branch into 'public' to help avoid merge conflicts
    git subtree pull --prefix=public \
        [email protected]:ProQuestionAsker/ProQuestionAsker.github.io.git master -m "Merge origin master"

    # In RStudio - Build website using blogdown
    build_site()

    # In terminal window - Pushing the updated 'public' folder to the 'sources' branch
    git add public
    git commit -m "Pushing updated public folder to source branch"
    git push origin "sources"

    # Pushing the updated 'public' folder to the 'master' branch
    git subtree push --prefix public 
        [email protected]:ProQuestionAsker/ProQuestionAsker.github.io.git master

The files all appear in my GitHub library as I'd expect them to, but Hugo does not seem to be rendering anything other than .md documents. Those all display as expected on the site. I'm not sure if this is a Hugo problem or a Blogdown problem, but I can't seem to get it to work.

Any help would be much appreciated!

like image 549
Amber Thomas Avatar asked Dec 16 '16 02:12

Amber Thomas


1 Answers

This issue is actually not an issue with blogdown, but after several more hours of searching and poking around, I found that it appears to be an issue with the theme I was using. Following the steps laid out above do work to let blogdown, hugo, and github pages work together just fine.

like image 175
Amber Thomas Avatar answered Sep 29 '22 07:09

Amber Thomas