This project contains all the files for the blog.
-
Create a folder under
posts/
with the folder name indicating the slug of the post -
Create an
ignored.qmd
1 file in the newly created folder- If using Python + Jupyter notebook from within VS Code, then create
ignored.ipynb
instead ofignored.qmd
- If using Python + Jupyter notebook from within VS Code, then create
-
Start writing
- If the post contains
Python
code, then thevenv
for the blog should be used. This is done automatically when using Quarto with RStudio (on my linux machine) and when using VS Code. See the section on managing python environments below.
- If the post contains
-
For R - When the post is ready for editing / proofreading, rename the file to
index.qmd
-
Save the image shown on the main page with these parameters, if generated via ggplot
ggsave(plot = plot_object, filename = "<plot_name>.png", device = "png", units = "px", width = 900, height = 800, dpi = 180, path = fs::path("posts", "<subdirectory>"))
plot_name
andsubdirectory
should be modified for each post. The dpi can be modified if the plot has some issues. -
Run
quarto preview
in the terminal, or click the Render button and see the post in the Viewer pane within RStudio. Same works for VS Code. -
When satisfied with the result, send
Ctrl+C
to the terminal to cancelquarto preview
- For previewing how a page would look on mobile, press `Ctrl + Shift + I` to access developer tools and click the mobile icon (same on Chrome and Firefox). Ideally nothing should be overflowing the page and creating lots of unnecessary whitespace on the page.
-
For converting the final ipynb file, this command should be run from the terminal (also see this)
quarto convert posts/<post_dir>/ignored.ipynb --output posts/<post_dir>/index.qmd
-
Optionally run styler on the source files (.R, .qmd). Useful to stage the source file to see what styler has changed and whether it should be accepted or rejected.
-
Run
quarto render
ifquarto preview
was used to review the file- If the change doesn't show up, then the subdirectory in
/posts
has to be rendered explicitly viaquarto render posts/<post-subdir>
- If the change doesn't show up, then the subdirectory in
-
Commit changes and push to master / main branch
-
Run
quarto publish gh-pages
-
Go do something else
For this, the renv documentation can be referred to. Important to periodically run
renv::status()
and
renv::snapshot()
Python packages are managed using pip. The local python environment for the blog can be activated by running the following from the root directory of the blog via bash
source blogpyenv/bin/activate
See this link for managing venv.
If new packages are installed or upgraded, then the requirements.txt
file should be updated by running
python -m pip freeze > requirements.txt
I should probably use poetry -- which I would for complex projects -- but will switch in the future if I end up having enough Python posts.
The reticulate
package in R is key when writing and running Python code from within RStudio.
See these links:
- Should the footnote be capitalized and end in a full stop? See this thread.
Footnotes
-
File is called
ignored.qmd
because of therender: "!ignored.qmd"
parameter in the_quarto.yml
file ↩