renv::init()
renv::status()
renv::install()
renv::status()
renv::snapshot()This is how we built this!
No place like home
This is a test of a personal website for jrfep.
These instructions are in English, but this site has content in multiple languages… I know it is confusing, but this is how I work. If you require clarifications please open an issue or send me a message.
All files are available in a GitHub repository. The mostly-harmless branch uses Quarto to build the site.
Libraries
To manage and update the version of libraries that we need, I used renv for some iterations, but it was complex to keep version across machines and different OSs…
When we use renv we need to run different commands, until all the changes have been synchronised1 :
But if we don’t update the .gitignore file things can get messy.
Render site
With Rmarkdown we could run this (in RStudio) to render site locally:
rmarkdown::render_site()Or preview one file
rmarkdown::render_site("presentations.Rmd")With quarto and RStudio we can open the Build tab and select Build Website…
Or we can go to the command line and render the site:
quarto render Sing All the rowboats in the meantime (optional).
And then launch a preview:
quarto previewIf this work, we can just git add, git commit and git push it to the repo and see the changes!
Alternatives
My other branch uses Jekyll (but I gave up on that some time ago, so do not expect any updates).
I also tried Rmarkdown for some time, might get back to that if this one does not work.
I was tempted to create a multi-lingual site using babelquarto:
install.packages('babelquarto', repos = c('https://ropensci.r-universe.dev', 'https://cloud.r-project.org'))But it was a short-lived experiment. I think it could work for simple sites, but would require more tweaks to make it work with my current site.
Font Awesome
They work well out of the box with Rmarkdown, but for quarto we need to install an extension.
Switch to the repository folder and checkout the git branch we are working on, and then:
quarto install extension quarto-ext/fontawesomeNow I can use {{< fa smile >}} in the text and get a , or {{< fa lemon >}} and get a .
Just in case
Prepare data for some pages
OSF data
here::i_am("how2/how-to-site.qmd")
if (!require(osfr)) {
install.packages("osfr")
library(osfr)
}
lst_osf <- osf_retrieve_user("me") %>%
osf_ls_nodes()
if (!dir.exists(here::here("data")))
dir.create(here::here("data"))
file_name <- here::here("data","OSF-data.rds")
saveRDS(file=file_name, lst_osf)GitHub data
here::i_am("how2/how-to-site.qmd")
if (!require(jsonlite)) {
install.packages("jsonlite")
library(jsonlite)
}
gh_rle_org <- read_json("https://api.github.com/orgs/red-list-ecosystem/repos")
gh_ces_org <- read_json("https://api.github.com/orgs/ces-unsw-edu-au/repos")
gh_jrfep <- read_json("https://api.github.com/users/jrfep/repos")
# https://api.github.com/search/repositories?q=user:jrfep&fork:false
# for each repo query the languages_url and summarise the lines of code for each language
file_name <- here::here("data","GitHub-data.rda")
save(file=file_name, gh_rle_org, gh_ces_org, gh_jrfep)Flexdashboard and iNaturalist
I use to have a dashboard here, but it works better with Rmarkdown than with quarto. SO I moved it to another site/repo.
There might be some alternatives in quarto for this, but haven’t tested them yet.
That OLD dashboard was inspired by this example: https://github.com/gonzalobravoargentina/inat_flexdashboard_ARG
To get the data I first install the rinat package:
here::i_am("README.Rmd")
if (!require(rinat)) {
install.packages("rinat")
library(rinat)
}Then I can download the observations from iNaturalist and save them in a data folder:
# Download observations and save to RDS file
user_obs <- get_inat_obs_user("NeoMapas",maxresults = 5000)
if (!dir.exists(here::here("data")))
dir.create(here::here("data"))
file_name <- here::here("data","iNaturalist-obs-NeoMapas.rds")
saveRDS(file=file_name, user_obs)To get the logo
With wget and ImageMagick, it is easy to download and resize in the terminal (bash) with two lines of code:
##mkdir
wget https://neomapas.github.io/assets/images/logo_NeoMapas_p.gif
magick logo_NeoMapas_p.gif -resize 100x148 resize_logo.gifFootnotes
Yes, I use this weird spelling…↩︎
