Bundle exec jekyll serve: builds a page2 folder with index.html - r

The problem
I'm running into a conflict error and a strange issue where my Homepage title is modified and "- Page 2" appears in the tab itself when I place a certain post inside the _posts folder. When I take this specific post out, the problem is resolved. The blog post itself works properly and I'm not encountering other issues. I'm running Minimal Mistakes theme and I'm knitting .Rmd reports in RStudio with GitHub flavored markdown.
Link to my main repo
Link to the specific post inside repo
Link to config.yml
YAML header for knitting .Rmd
title: "Data visualisation"
date: "`r Sys.Date()`"
output:
md_document:
variant: gfm
Knitting options for Rmd
library(knitr)
# macOS
# setwd("~/Developer/mkruisbrink.github.io/_reports/R-for-data-science/01-explore/01-data-visualisation/")
# Windows
setwd("D:/Max Kruisbrink/Developer/mkruisbrink.github.io/_reports/R-for-data-science/01-explore/")
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
# define knitr paths for macOS
#base.dir <- "~/Developer/mkruisbrink.github.io/"
# define knitr paths for Windows
base.dir <- "D:/Max Kruisbrink/Developer/mkruisbrink.github.io/"
base.url <- "/"
fig.path <- "assets/reports/R-for-data-science/01-explore/01-data-visualisation/"
# set knitr parameters
opts_knit$set(base.dir = base.dir, base.url = base.url)
opts_chunk$set(fig.path = fig.path)
I get a neat .md file which I can place inside my _posts folder with some yaml header. All other posts are processed fine, the error only appears when I place this specific post inside the folder.
YAML header for post
title: "The basics of data visualisation in R"
excerpt: "These are the basics of visualizing data in R, using only the tidyverse functionality"
header:
overlay_image: /assets/images/midjourney-optimised/big-computer-screen-financial-dashoard-optimised.jpg
category:
- Exploration
What I've tried so far
I've tried the following:
Spent at least 2 hours on online research, didn't find any proper relevant sources to help me out here
Manually removing from and adding back all posts from the _posts folder to figure out the problem lies with this specific post
Running bundle update and bundle install
Double checking YAML headers for posts and the config file
Checking .Rmd settings for other reports that are knitted in the same way and cause no issues
Removing the post content from the .md file to see if the bug came from something in the code perhaps
Replacing the whole YAML header with that of a post that causes no issues
Ran --trace in combination with bundle exec jekyll serve for the same conflict results
Ran --verbose in combination with bundle exec jekyll serve and I could find ONE extra instance of something writing index.html to _site. So the following appears twice in the log. I know the culprit is this post but how to get more info on what is causing it?
Writing: D:/Max Kruisbrink/Developer/mkruisbrink.github.io/_site/index.html
Conclusions and questions
I'm starting to run out of options for my current skill level of debugging.
Could it be something relating to _includes or _layouts? I might have tweaked layouts but pretty sure I left the includes folder alone. But why would other posts be unaffected?
Could it be plugin related? I had no problems up until last week suddenly and didn't change any plugin.
Should I update to the latest theme, removing any customization I've done to rule that out
I'm running this in my gemspec
source "https://rubygems.org"
gemspec
gem "webrick"
gem "jekyll-remote-theme"
gem "tzinfo" #windows dependancy?
gem "tzinfo-data"
Can someone point me in a direction here? Getting slightly clueless and I want to be a little cautious with my re-rolling. Thanks in advance!
Edit 2022-12-28
When I remove the permalink: \ from the main index.html file, the error is resolved but when building the site with bundle exec jekyll serve a strange page2 folder is created in _site with its own index.html
However, I still think something is off with certain posts as the error is resolved when I move them to _drafts.
Anyone any thoughts?

There was an issue with the _config.yml file where I was mixing liquid syntax and the pagination plugin.
# Outputting
permalink: pretty
paginate: 5 # amount of posts to show
paginate_path: /page:num/
timezone: Europe/Amsterdam # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# Plugins (previously gems:)
plugins:
- jekyll-paginate
changing the outputting into the following solved my issue.
# Outputting
permalink: /:categories/:title/
timezone: Europe/Amsterdam # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
My final cue was the page2 folder that was being built and the fact that EVERY post that I added to my _posts folder above the number 5 was causing issues.

Related

`README` badges not getting rendered properly in `pkgdown` website

I have thus far created 6 different pkgdown websites for my R packages (e.g., ggstatsplot, kittyR, etc.) and none of them ever had the following issue.
For the first time, running the following command
pkgdown::build_site(
lazy = FALSE,
run_dont_run = TRUE,
seed = 123,
devel = TRUE
)
is not rendering README badges and I am not sure why since the yaml I am using is similar to my other packages. I had raised issue on pkgdown GitHub repo, but it didn't help.
More explicitly, here is what my README looks like-
README: https://github.com/IndrajeetPatil/ipmisc/blob/master/README.md
And here is what the pkgdown output looks like-
pkgdown: https://indrajeetpatil.github.io/ipmisc/
I get no warnings or errors while building the website., but as can be seen here, the badges are not rendered at all on the homepage. Any ideas on why this might be happening or how to resolve it?
Thanks in advance.
I was able to replicate the issue with the README file you linked. I noticed that adding text (any characters) in backticks before the first heading made the badges re-appear. The reason has to do with how pkgdown parses the readme to look for badges. As a workaround, you could try adding the word "test" in backticks at line 16 of your README.Rmd file.
This seems to have now been resolved in the dev version of pkgdown. See the discussion of the issue for more details and consider using <!-- badges: start --> and <!-- badges: end --> around the badges section.

SASS files conversion in blogdown (sam theme)

I am trying to build a website using blogdown, and the Hugo theme Sam.
This theme has SASS files that get converted into a minified css file.
When I change something in the SASS file, like for example the background color, it is not taken into account when using serve_site.
Is there a way to make this work using blogdown?
A way to reproduce the issue is:
Create an empty directory called for ex. test_sam, and set it as a working directory
then do:
library(blogdown)
new_site(theme = "victoriadrake/hugo-theme-sam")
Try to change something in test_sam/themes/hugo-theme-sam/assets/sass/style.sass, for example:
change
html
background-color: $dark-grey
to
html
background-color: $white
This doesn't produce any change.
Color variables (such as $white) are defined in test_sam/themes/hugo-theme-sam/assets/sass/_vars.sass
The odd thing is that if I change it to an undefined variable name like $yellow, I get the following error message:
Building sites … ERROR 2019/12/27 20:44:39 Transformation failed: SCSS
processing failed: file "stdin", line 11, col 23: Undefined variable:
"$yellow". Total in 197 ms Error: Error building site: logged 1
error(s)
which shows that blogdown does access the sass files to build the site.
I have very little knowledge about website building nor css, so maybe there is something quite obvious that I'm not getting.
Thanks for your help!
Although late to answer, I solved this issue with the same theme by setting the "blogdown.generator.server" option to TRUE.
options("blogdown.generator.server" = TRUE)
blogdown::serve_site()
Update: This actually seems to be a common issue with the Sam theme specifically. The theme uses some tools not included with Hugo, and you have to download them separately. It's addressed in the README.
Open Terminal and run:
npm install -g postcss-cli
npm install -g autoprefixer
After that, blogdown::serve_site() worked normally for me. It also fixed some plot rendering issues I was having.

rmarkdown::render_site() Error in rmarkdown::render_site() : No site generator found

I am trying to knit together 3 files using this example: http://rmarkdown.rstudio.com/rmarkdown_websites.html
My files all share the same directory, which has been set in the RStudio build options. I literally copied the YML from the examples with my own file names. Even if I copy the examples directly, I get the same error.
I even ran the site_generator function from the RMarkdown Github: https://github.com/rstudio/rmarkdown/blob/master/R/render_site.R#L157
I noticed there are options for custom generators, which I do not want. All I would like to do is be able to knit together several markdown files into a single webpage and then create a navbar with tabs for each page/section.
I got the same error when attempting to build with an incorrectly named YAML config file. Specifically, the RStudio build option for a website requires that the config file be called _site.yml.
Verify that this file exists and that you're using the extension .yml rather than .yaml (even though the latter is preferred).
What helped for me was putting the line site: bookdown::bookdown_site back to index.Rmd.
lord, my issue was that i didn't set my working directly to where my _site.yml file and index.Rmd files are stored - the little things!
I fixed this error using this steps.
1-) RStudio-Tools-InstallPackages
2-) Install From should be CRAN Repository.
3-) write this command --> install.packages("install.packages("rmarkdown")")
4-) Click Install
And problem has gone... And this is output.
This error also appears when there is a format issue in the yaml section of index.Rmd.
In my case, I encountered the error when the opening "---" in index.Rmd had a couple of white spaces " ---".
If you are having this problem, I would recommend knitting index.Rmd by itself (not building the book) before trying anything more drastic.

Jekyll Converter for R Markdown

I am trying to write a Jekyll converter for R Markdown files. I created RMarkdownConverter.rb and placed it in my _plugins directory. I have verified that other plugins are working but this one is not. I also don't see any error messages, including the ones I put in myself. It seems this is not being used. However, Jekyll is generating an HTML file for my .Rmd file but simply processes the R chuck as code chuck. Any help or thoughts would be greatly appreciated.
RMarkdownConverter.rb file:
module Jekyll
class RMarkdownConverter < Converter
safe true
priority :low
def setup
STDERR.puts "Setting up R Markdown..."
return if #setup
require 'rinruby'
#setup = true
rescue
STDERR.puts 'do `gem install rinruby`'
raise FatalException.new("Missing dependency: rinruby")
end
def matches(ext)
ext =~ /Rmd/i
end
def output_ext(ext)
'.html'
end
def convert(content)
setup
STDERR.puts "Using R Markdown..."
R.eval "require(knitr)"
R.eval "render_markdown(strict=TRUE)"
R.assign "content", content
STDERR.puts content
R.eval "out <- knit(text=content)"
R.eval "print(out)"
end
end
end
The contents of my first R Markdown post:
---
layout: post
title: Using (R) Markdown, Jekyll, and Github for Blogging
published: true
tags: R R-Bloggers Jekyll github
type: post
status: publish
---
First, we need to install [RinRuby](https://sites.google.com/a/ddahl.org/rinruby-users/) to call R from Ruby. In the terminal, execute:
gem install rinruby
First R chuck:
```{r}
2 + 2
```
Try replacing the last few lines with the following
R.assign "content", content
R.eval "knitr::render_markdown(strict = TRUE)"
R.pull "(knitr::knit2html(text = content, fragment.only = TRUE))"
I think you need R.pull to copy the contents of R output to Ruby. Moreover, I would recommend directly converting from Rmd to html. I have used this strategy successfully in working with Ruhoh which is another ruby based blogging platform.
UPDATE. It is very odd but using the extension rmd seems to conflict with md. I changed it randomly to ram and jekyll seems to pick it up correctly. I am not sure why.

Getting .Rprofile to Load at Startup

I have a global ~/.Rprofile file and another .Rprofile file located in my project's current working directory and both of the have the following contents:
.First() <- function() {
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
system(paste("pandoc", shQuote(inputFile), "-s --webtex -o", shQuote(outputFile)))
}
)
}
Unfortunately, when I open the RStudio app neither of them appear to be working. The aim of what I'm trying to do is to make the "Knit HTML" button render the Markdown file, which has inline LaTeX, process through Pandoc using webtex as the LaTeX renderer.
Does anyone know how I check whether my .Rprofile files are loading at startup?
Thanks for any help!
POST ANSWER EDIT (after Josh's answer):
For clarity, my working project's .Rprofile file (which works) now reads as such:
options(rstudio.markdownHTML =
function(inputFile, outputFile) {
system(paste("pandoc", shQuote(inputFie), "-s --webtex -o", shQuote(outputFile)))
}
)
\\ you will need to end with a blank carriage return underneath
The R docs should help to see how to deal with .Rprofiles. Execute the following at the console:
> ?Startup
The relevant portion of this indicates that you need to put your project .Rprofile in the initial working directory that will be loaded when starting the project. Thus if your project is ~/foo/foobar.Rproj, then you should have your profile be ~/foo/.Rprofile and make sure that when starting up, the initial working directory is ~/foo/. You can see this in the title bar at the top of the console pane in RStudio.
Also to confirm that the correct .Rprofile is actually being loaded, I would personally put in a test to see which (if any) profile is being picked up. For example, include:
print("This is the Rprofile inside the foo project!")
Here is another example about getting this to work:
http://support.rstudio.org/help/discussions/suggestions/1095-different-rprofile-for-a-project#comment_15690293
Finally, if the correct .Rprofile is being loaded inside the project, then there must be something wrong with your code. Looks like you got this from our docs though, so if you get the profile loaded, and continue to have problems, please let us know. You can post a new discussion on our support thread.
Josh
Product Manager - RStudio

Resources