To be able to use goodpress to publish posts on your WordPress website, you need to perform a few setup steps. You only need to do these once, so that’s only potentially painful at setup.

You might not need to tweak syntax highlighting and math stuff if you, well, never show code or never show math equations in your posts.

Authentication

From WordPress point-of-view this package is a “remote application” therefore it needs your website to use an authentication plugin. At the moment, for the sake of simplicity, this package only relies on Application Passwords.

You cannot install plugins if you use wordpress.com (unless you have a costly business plan there), therefore with wordpress.com you cannot use the REST API. There are paid services out there providing a domain name, hosting and a one-click WordPress install, for a few dollars a month, that you could use if you don’t roll your own server.

Here’s what I did to be able to use this package on my test website:

  • Installed and activated the Application Passwords plugin. Don’t forget to keep your WordPress plugins up-to-date especially because of security updates.
  • Created a new user with editor rights, not admin, and from the admin panel I created an application password for “rmarkdown” for that user. Doing this for an user with restricted access is safer.
  • In .Renviron, save username as WP_USER and application password as WP_PWD. Re-start R. Keep .Renviron safe, it contains secrets! Here’s an example of .Renviron below, the empty line at the end of the file is needed.
WP_PWD="your application password including space e.g. blabla blabla blabla blabla NOT your WordPress main password"
WP_USER="yourusername"

Syntax highlighting

For R

To get syntax highlighting for R blocks, at the moment you need to add custom CSS (once, like the plugin setup stuff).

You could edit colors that are in the CSS file.

Later I hope to make this process easier, maybe by adding inline styles.

Other languages

I haven’t explored that yet.

Math

To be able to use math with MathJax, you’ll need to customize your theme.

From WordPress interface go to Appearance > Theme Editor. Add the lines below (that come from MathJax docs) to the <head> div of header.php, then save.

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

Then refer to the usage vignette.