implement gravatar for the authors of the posts

dear community, I want to implement gravatar in a blog to show the authors of the posts and in case they do not have an avatar, a reference image will be shown.
create a hidden label with ID referring to email

{{ }}

with Jquery I access the label, pass it through a code block to get the hash and send it to the DOM.

(function ($) {
“use strict”;

let email = $(’#x1’);

const { createHash } = require(‘crypto’);

function computeHash (email = ‘’) {
// Ensure email is a string
email = (typeof email === ‘string’) ? email : ‘’;
// Trim the leading and trailing whitespaces
email = email.trim();
// Transform to all lowercase characters
email = email.toLowerCase();
// Compute the MD5 hash
const hash = createHash(‘md5’).update(email).digest(‘hex’);
return hash;

$(’#x2’).attr(‘src’, ‘’ + );


but it’s not working for me

Can you share screen shot, link, describe what you see and expect ? Are you getting a JS console error?

Also please use Markdown codeblocks to make your code more readable.



Or share a link to a code sharing snippet site

Can you test smaller pieces of your code? E.g hardcoded value on html page with no Jekyll. Or Jekyll page that doesn’t use Jquery but just logs to the console?