Jekyll — Add An Affiliate Disclaimer To Specific Posts

On my website (built in Jekyll) some of the links used are affiliate links. To let people know this, I include a disclaimer at the top of relevant pages.

Instead of manually copying and pasting this text for each new article I write, here’s how I implemented an affiliate disclaimer to specific posts or pages.

In the _includes folder, create a file called affiliate-disclaimer.html

Add the following code to that file:

If you want to implement this on your own Jekyll site, you can change the actual content of the affiliate disclaimer message.

In the _layouts folder, add the code below to any page templates that may have affiliate links.

In my case, I have 2 files: article.html and book-note.html

This code will include the affiliate disclaimer file to those page templates:

The final step is to include a line of YAML metadata to relevant articles and pages:

When this code is added to your pages and articles, it will trigger the first piece of code that includes the affiliate disclaimer text.

If you’re trying to save on load/build times and want to cut down on the amount of includes you use, you could just copy and paste the affiliate-disclaimer.html code directly into your page templates.

This article was originally published over on my website: Jekyll — Add An Affiliate Disclaimer To Specific Posts

Design + Productivity. Learn everything you need to improve your design skills and stay productive. My Book: