install hugo
If got error message with remotes::install_github, try this: remotes::install_github('rstudio/blogdown')
check package version,
blogdown::hugo_version()
[1] ‘0.74.3’
pick a theme and install
blogdown::new_site(theme = "dillonzq/LoveIt")
To start a local preview: use blogdown::serve_site(), or the RStudio add-in “Serve Site”
The web server can be stopped by blogdown::stop_server(), and it will always be stopped when the R session is ended, so you can restart your R session if stop_server() fails to stop the server for some reason.
insert images when posting
Just save images in in the same folder as the post document, for example, posts/2022-08-16-无他-但手熟尔/xxx.png
post a new Rmarkdown-generated file
Choose .Rmd format in New Post and start writing.
When done, use knit to check the Rmarkdown file contain no bug (you may need to change to the working folder if there requires reading in data files), then delete the .html file.
Restart R, in the blog folder, use serve site in the Addins to generate the website page.
tricks
- I used
.Rmdinstead of.Rmarkdown..Rmdleads to.htmlfile and.Rmarkdownto.markdownfile whenserve site. Both viewed fine on my laptop, but onlyhtmlshow all R plots when deployed on netlify. - With all
Rmdfiles ready, runserve sitelocally to make sure all.htmlfiles are generated and properly configured, then sync to github. - Feel free to delete
themes/LoveIt/exampleSite/folder. - On the
Categoriespage, if you didn’t see blogs organized into different categories, double check if you have includedcategoriesortagsat the very beginning of each Rmd file, for example:categories:
- statistics tags:
- power analysis
- statistics
- if you make any changes in
.Rmdfile, delete the original.htmlfile, and useserve siteto re-generate the.htmlfile.
Useful tutorial: