See it in action:
I'm assuming a Jekyll + Netlify configuration, but most of this is applicable to other static site generators.
Follow Facebook's steps here.
Use the User Token Generator to generate a starting token.
Instagram Access tokens last 60 days, then need to be refreshed. Use the Instagram Token Agent to automatically refresh tokens. Deploy the site to Heroku, using the starting token from the previous step.
Notes:
Copy/paste jekyllgram.rb
(in this folder) into your _plugins/
folder. Be sure to replace @access_token_heroku
with your own Heroku app name.
Access the jekyll feed as {% jekyllgram %}
. Example:
{% jekyllgram 10 %}
<a href="{{photo.permalink}}">
<img src="{{photo.media_url}}" />
</a>
<p>{{photo.caption | newline_to_br }}</p>
<p class="timestamp">{{photo.timestamp | date_to_string }}
{% endjekyllgram %}
(use the liquid tag newline_to_br
to convert \n
into <br>
in the caption)
Options:
{{photo.permalink}}
: the link to the post{{photo.media_url}}
: the url of the post's image or video{{photo.caption}}
: the caption of the post{{photo.timestamp}}
: the date and time the post was added{{photo}}
This will call the Instagram API every time your site builds.
Credit: jekyllgram.rb
is based off of https://github.com/benbarber/jekyll-instagram.
This will call the Instagram API every time someone accesses your site. Unfortunately, this makes it easy to exceed the API call limit.
Deploy your site to Netlify, then create a Zapier zap so that a new Netlify deploy is created when a new post is added to instagram.
Contributors to this repo are welcome!