Blog post: "Using Cloudinary for GitHub Pages website"
Tags: cloudinary, javascript, githubpages
Published: 2020-11-04 21:48:38

---
title: Blog post: "Using Cloudinary for GitHub Pages website"
published: true
description: Getting to know cloudinary
tags: cloudinary, javascript, githubpages
//cover_image: https://direct_url_to_image.jpg
---
Last night I watched [a Twitch stream][JASONSTREAM] with [Jason Lengstorf][JASONWEB].

Jason was doing a 90-minute "[Learn With Jason][JASONLEARN]". I have been following [Jason on Twitter][JASONTWITTER], but I have never watched his streaming.

Jason was joined by [Maya Shavin][MAYATWITTER] a senior frontend developer from [Cloudinary] and the episode was entitled "Let's Learn Nuxt!". [Nuxt, or Nuxtjs][Nuxt], is a framework built on top of [Vue].

I am quite keen on Vue, but not getting much exposire, so getting an introduction to Nuxt I gathered would be quite interesting and I was not really in the mood for coding, but not in the mood for _flow_ TV either.

The stream was absolutely awesome. Nuxt is really cool and it reminded me that I really, really need to do some more Vue.

As I wrote in the introduction, Maya Shavin works as a senior frontend developer with Cloudinary and media serving service. Jason and Maya implemented a basic Nuxt application (_they only had 90-minutes_) rendering images served by from Jasons account with Cloudinary using different features offered by Cloudinary.

As Jason and Maya pair programmed, Maya gave a introduction and overview of the JavaScript API offered by Cloudinary and *THIS* really _triggered me_ - this was exactly what I needed.

I have written previously blogged about using JavaScript in [GitHub Pages][githubpages] and I am a great fan of GitHub Pages.

- "[Experimenting with GitHub Pages and JavaScript and Putting Everything to Use][DEVTO1]"
- "[Experimenting with GitHub Pages and JavaScript and External Data][DEVTO2]"
- "[Experimenting with GitHub Pages and JavaScript][DEVTO3]"

And I have been [working on creating websites][wordpress] for my different GitHub repositories and using GitHub Pages. One of them a simple website for a Perl distribution of mine: [Date::Holidays][metacpan].

I was not satisfied with the handling of the chosen background image, taking into consideration the _responsiveness_ (or lack thereof) I think is required and my lacking skills in this particular area.

When Maya went over the different features of Cloudinary, it struck me, this this could be quite useful in my case.

I decided to start with some alterations to the CSS, but I expected things would go faster if I had a locally running instance of my website.

Luckily this is quite easy with GitHub Pages, which is using static sites based on Jekyll.

I added a `Gemfile` to my repository installed and got it running. Please see one of my [earlier blog posts][DEVTO3] for more elaborate details.

With the CSS changes in place, I got to the picture. I started by uploading. "[Sorry]". A free high resolution image by the photographer: [Tim Mossholder][TIMUNSPLASH] from [Unsplash]. The background image and I manually manipulated in different graphics programs to get the expression and integration I wanted.

I opened it in a browser window and stated applying different Cloudinary features on the original image to resemble, what I had previous done by hand.

This process is so easy and you can see the result straight away,

The final URL ended looking like this:

```html
https://res.cloudinary.com/jonasbn/image/upload/h_512,q_auto:low,c_fill,g_center,e_blur:200/tim-mossholder-C8jNJslQM3A-unsplash_zkhz2a.jpg
```

Now lets walk through the different parts of the Cloudinary features used.

- `g_center`: the original image is huge, so I started by defining `gravity` to `center`, meaning the images would _gravitate_ towards the center of the image when rendered (ref: [documentation](https://cloudinary.com/documentation/image_transformations#control_gravity))

- `c_fill`: this was used in combination with automatic cropping, as suggested in the documentation (ref: [documentation](https://cloudinary.com/documentation/image_transformations#automatic_cropping_with_the_fill_mode))

- `h_512`: I set the hight to `512` as was the image I had created based on "[Sorry]". I am not sure this is the best strategy in regard to responsiveness, but I am still learning. (ref: [documentation](https://cloudinary.com/documentation/image_transformation_reference#height_parameter))

- `q_auto:low`: I set the quality to `low`, reducing the size. The original is very high quality, way beyond what I need (ref: [documentation](https://cloudinary.com/documentation/image_transformations#automatic_quality_and_encoding_settings)). The original image is: 4.880.246 bytes (4,9 MB on disk), with the dimensions: 7200 × 4800. The image served by [Cloudinary] to a regular browser with the specified parameters applied is: 20.626 bytes (25 KB on disk), with the dimensions 768 × 512.

- `e_blur:200`: finnally I applied a blur effect, so the image would step more in the background compared to the other elements on the page, (ref: [documentation](https://cloudinary.com/documentation/image_transformations#blurring_pixelating_and_sharpening_effects))

The URL was [placed in the CSS](https://github.com/jonasbn/perl-date-holidays/blob/master/assets/css/style.scss#L8) and replaced the the reference to an image included with the respository.

I iteratively tested rendering of the locally running website in several browser windows at the same time, emulating different devices and finally, just to be sure, on my smart phone and I must say I am quite satisfied.

The final product can been be visited at [jonasbn.github.io/perl-date-holidays][dateholidaysweb].

I was very impressed with Cloudinary and was very entertained and inspired by Jason's stream and it will not be the last episodde I watch.

Thanks to [Jason Lengstorf][JASONWEB] and [Maya Shavin][MAYATWITTER] and the people at [Cloudinary].

[JASONWEB]: https://www.jason.af/
[JASONSTREAM]: https://www.twitch.tv/videos/790916377
[JASONTWITTER]: https://twitter.com/jlengstorf 
[JASONLEARN]: https://www.learnwithjason.dev/
[MAYATWITTER]: https://twitter.com/mayashavin
[Cloudinary]: https://cloudinary.com/
[Nuxt]: https://nuxtjs.org/
[VUE]: https://vuejs.org/
[DEVTO1]: https://help.github.com/en/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll
[DEVTO2]: https://help.github.com/en/github/working-with-github-pages/testing-your-github-pages-site-locally-with-jekyll
[DEVTO3]: https://dev.to/jonasbn/blog-post-experimenting-with-github-pages-and-javascript-and-putting-everything-to-use-47i2
[TIMUNSPLASH]: https://unsplash.com/@timmossholder
[Sorry]: https://unsplash.com/photos/C8jNJslQM3A
[dateholidaysweb]: https://jonasbn.github.io/perl-date-holidays/
[metacpan]: https://metacpan.org/release/Date-Holidays
[wordpress]: https://lastmover.wordpress.com/2017/01/01/github-pages/
[githubpages]: https://pages.github.com/
[Unsplash]: https://unsplash.com/