Skip to main content

Crossposter

Crosspost your articles to dev.to/medium.com/hashnode.com from the command line

  • Crossposter is a script(Python/BASH) to automate crossposting to platforms like dev.to, medium.com and hashnode.com. The script takes in markdown version of your post with a few inputs from you and posts it to those platforms. You would require a token/key for each of those platforms to post it from the command line.

There are two versions of the script:

The actual script is still not perfect (has a few bugs). Though it posts on dev.to and medium.com easily, the hashnode.com is buggy as it parses the raw markdown into the post and doesn't render as desired. So, its a under-development script, fell free to raise any issues or PRs on the official GitHub repo.

Crossposter Python Script

The python script initially is now a python package. You can essily install and configure it as per your requirements.

PyPI version

Dependencies for the python script:

Running the script:

Make sure you install the python package with pip or any other package manager like pipenv or poetry you would like:

pip install crossposter

# OR

pipenv install crossposter

# OR

poetry install crossposter

# OR

pipx install crossposter

Configuration

  • Create a config file config.json for customization
  • Create a folder for the output files

Inside the config file, you can specify the two attributes for the working of the script. The first is for generating the canonical_url for the post and the next is the output folder for the generated files for different platforms.

{
  "blog_link": "https://www.meetgor.com/",
  "output_folder": "crossout"
}

One it is installed, you can then specify the markdown file which you want to use as a post with:

crosspost <filename>.md

# OR with pipx

pipx run crossposter

This will prompt you for a few things, if not provided in the frontmatter of the command. There will be need of inputs like title, description, tags, status, cover-image, etc. If you provide it in the frontmatter, there will be no input prompt. Once the input is taken or the frontmatter is picked, it will set those frontmatter for various publications automatically.

# post to dev.to

crosspost <filename>.md --dev


# post to codenewbie.org

crosspost <filename>.md --cdb


# post to medium.com

crosspost <filename>.md --med

image

image

For further help on CLI command, you can get the help argument

crosspost --h

ShellScript is no longer developed because of content parsing issues, it has been converted to a python package

Though some basic functions will work in shell script like simple frontmatter, devto and medium posting.

Crossposter Shell Script

The crossposter shell script is a file to be used from a linux/unix command line in a shell environment. The procedure to execute the file is as follows:

Run the script on a bash interpreter with the command:

bash crosspost.sh

OR

bash crosspost.sh file_name.md

For posting the article you need to provide the following details:

Front-Matter

Meta data about the post

  • Title of Post
  • Subtitle of Post
  • Publish status of post(true or false)
  • Tags for the post (comma separated values)
  • Canonical Url (original url of the post)
  • Cover Image (URL of the post's image/thumbnail)

This information is a must for dev.to especially the title. This should be provide in the same order as given below:

---
title: The title of the post
subtitle: The description of your article
published: true
tags: programming, anythingelse
canonical url: url of your original blog
cover_image: coverimage_url
---

There is no need to enclose any of them with quotation marks. Published argument will be true if you want to publish it and false if you want to keep it in your Drafts.

In the demonstrations, we just need to enter the tokens once. The tokens will be stored locally in the keys.txt file and retrieved later within the script.

Posting on dev.to:

Posting on dev.to requires their API key which can be generated by going on the Dev Community API Keys. From there you can generate a new key with any name you like. You just need to enter the key to CLI once or manually enter in the keys.txt file with the format dev.to:key on the first line. This will be used for the future cross-posting whenever you execute the shell script(bash crosspost.sh)

You can provide the front matter manually in your markdown file or you will be prompted for the input. So, that is all you will require for posting on dev.to from the Command line.

Lets see the script in action

dev.to

If you want to add in more stuff to the post, you can check out the DEV.to API docs which is powered by Forem, there a ton of options you can hook to the front-matter in the shellscript.

Metadata

Release files for crossposter 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crossposter 0.6.0
File Size Uploaded
crossposter-0.6.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crossposter 0.6.0
File Interpreter ABI Platform
crossposter-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.1 kB

Release files / crossposter-0.6.0.tar.gz

Download URL crossposter-0.6.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
88431ef02050fdb40e9fe2b7e9377617a9a3c254c52c52ae11e1ffc8486a74f4
BLAKE2b-256 checksum
How to use checksums
3685d3a6d0abd2798c1657b644771ba21ec5cdd357246b2ccf861729ed7f7f0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / crossposter-0.6.0-py3-none-any.whl

Download URL crossposter-0.6.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a511a70d48333cab1e4139d76f992e267ea1fc8edd4b55c9cd828d3cc1490944
BLAKE2b-256 checksum
How to use checksums
176d7f3ce4555321dee9743f6519b73e9d6f883d8fae9e53f2af1f8bc91dd5ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page