DEV Community

b0bby_seal
b0bby_seal

Posted on

How To Post Articles on Dev.to Using Ruby From The CLI

Requirements:

  • ruby -v ~< 2.50
  • json -> (gem install json)

Steps

Generate an API key
Goto: settings -> account -> DEV Community API Keys
Click Generate



Copy the <api_key> to your buffer


Add this line at the end of your ~/.bashrc file


export DEVTO_KEY="<paste_api_key_here>"


Copy this gist into /usr/local/bin/ as: publish

sudo cp publish /usr/local/bin/


Modify permissions: sudo chmod +x /usr/local/bin/publish



Do a test run: publish hello_world.md DEVTO_KEY



If it worked; Great! If it didn't, leave a comment where you got stuck.

NOTE: In order to make your post public; make sure to set published: true so that it shows on your dashboard. You can only add maximum of 4 tags when adding tags. Titles can not have special characters otherwise you will have formatting issues.

Here's the formatting I use:

 ---
  title: Hello World,
  published: true,
  tags: ["helloworld", "100daysofcode"]
 ---

  Your content goes here
Enter fullscreen mode Exit fullscreen mode

Top comments (0)