Crosspost to Medium Generator for Jekyll and Octopress
This plugin makes it possible to automatically syndicate your posts to Medium from your Jekyll and Octopress projects.
Setup
- Sign up for a Medium account (if you don’t already have one). Log in.
- Go to your settings page and look for "Integration Tokens". Generate one. Save it to your Environment Variables as MEDIUM_INTEGRATION_TOKEN.
- Visit
https://api.medium.com/v1/me?accessToken=
, adding your Integration Token to the end of that URL - Grab the id from the JSON provided and save that to your Environment Variables as MEDIUM_USER_ID.
- Copy
jekyll-crosspost-to-medium.rb
to your site’splugins
folder.
Publication Setup
If you are going to publish your posts to a publication, we need the publication ID
- follow the same basic setup steps getting you Integration token and your user ID
- visit https://api.medium.com/v1/users/USERID/publications and fill in USERID with the user id you found in the basic Setup
- grab the id that matches your publication name and save that to your Environment Variables as MEDIUM_PUBLICATION_ID.
- in _config.yml add publication: true under yout
Installation
This plugin can be installed in two ways:
- As a Ruby Gem:
gem install jekyll-crosspost-to-medium
- Via
_config.yml
addjekyll-crosspost-to-medium
to yourgems
list; or - Add
require 'jekyll-crosspost-to-medium'
toext.rb
in yourplugins
directory (new or existing one)
- Via
- By directly copying
jekyll-crosspost-to-medium.rb
(found in thelib
directory) into yourplugins
directory.
Crossposting
Add crosspost_to_medium: true
to the front matter of any post you would like to crosspost to Medium.
Configuation
This plugin takes a number of configuration options. These allow you to customise how the plugin works and what metadata is included when you syndicate to Medium. The following options are available:
jekyll-crosspost_to_medium:
enabled: true | false
cache: .jekyll-crosspost_to_medium
status: public (default) | draft | unlisted
license: all-rights-reserved (default) | cc-40-by | cc-40-by-sa | cc-40-by-nd | cc-40-by-nc | cc-40-by-nc-nd | cc-40-by-nc-sa | cc-40-zero | public-domain
text: '<p><i>Your (optional) signoff for the post.</i></p>',
backdate: true (default) | false
-
enabled
Default:
true
Controls crossposting globally. Setting this to false will skip the processing loop entirely which can be useful for local preview builds.
-
cache
Default:
[source directory]/.jekyll-crosspost_to_medium
The name of the diretory where crossposted files will be logged. Make sure this file gets checked into your Git repo if you work from multiple computers. This will ensure you never crosspost an entry more than once.
-
status
Default:
public
The status your post is given when it is syndicated to Medium.
-
license
Default:
all-rights-reserved
The license your post is given when it is syndicated to Medium.
-
text
Default:
<p><i>This article was originally posted <a href="{{ url }}" rel="canonical">on my own site</a>.</i></p>
Optionally, provide a string to override the default text for the canonical link back to the source post. A
{{ url }}
placeholder should be provided to indicate where to put the canonical link, e.g.,Some <a href="{{ url }}">link</a>
-
backdate
Default:
true
Whether or not to use the original date & time of publication when crossposting.
A Note on Environment Variables
If you are having problems setting up Environment Variables, check out these guides:
Credits
Many thanks to Jeremy Keith for sharing his process (and PHP code) for getting this working on his own site.