How to add Inline Ads in Jekyll blog | And increase your CTR
September 17, 2019 · 2 mins read
With the coming of new blogging tools like dev.to and medium. People tend to post mostly on those websites. But owning a separate blog on GitHub using Jekyll can give you a lot of freedom. You can do whatever you want with it. While this issue is controversial, there is nothing wrong to monetize your work. If you love to write and blogs (like I do) you can add ads to your blog. Maybe you have launched a course and want to publicize it to your readers.
Strategy for adding inline ads in Jekyll blogThe strategy here is pretty simple, we want to show a Google ad after every
tenparagraphs of the content. For accomplishing this, we will have to concentrate on the file,
_layout/post.htmlHere is the old content of the file.
29th line the most important line and is responsible for showing the content of the post.
Adding inline ads in Jekyll blog: Tech Strategy
- Split the blog content on the basis of
- After every 10 Paras, add an ad.
entrywith this code. On the 4th line, we split the
<p>tag and assigned it another variable
content_para. Then we are looping over this
content_paraand start printing it one by one. Inside each loop, we are checking the loop index and finding its
modulo 10which will give its remainder value and assigning the value to a variable
para_number. The value of
para_numberwill be 0 when loop index is multiple of 10 i.e. 10, 20, 30 and so on. You can add whatever you want to in the place. If you want to publicize your new course, you can do it. That’s it for today, I hope you liked the post. Please share it with your friends. Also, it would help us if you leave a comment and appreciate if this helped you. If you have some doubt feel free to reach out using the comments section.
Please share your Feedback:
Did you enjoy reading or think it can be improved? Don’t forget to leave your thoughts in the comments section below! If you liked this article, please share it with your friends, and read a few more!