Getting started
After creating an account over at manage.comments.sh you will need to setup your website to integrate with the comments.sh api.
Register domain
The first step is to add your domain to the comments.sh registry. This way our api knows it should process any requests for your website.
Registering your domain can be done in the Authorized Domains UI at manage.comments.sh.
- Click on the Add domain button
- Enter your domain including subdomain, for example https://www.example.org
- Click on Save
Now your domain is registered and authorized to use the comments.sh APIs.
Import script
Next you’ll need to connect your website to comments.sh APIs. In order to get you up and running in no time we provide you with a ready to use client.
Simply include the following javacript import on all pages you would like to make use of our comments system.
<script defer src="https://import.comments.sh/v1/static/bundle.min.js"></script>
Note: if you would like to write and use your own client please refer to the API documentation here
Add template
Last step is to add a template that our client will use to display the form and comments on your pages. The code snippet below is a basic template showing a comment box with privacy checkbox. Include this on all the pages that include the client script in the location where you want to show the comments.
Don’t change any of the id’s or data attributes as they are used by the default client. You can find more details here if you want to customize your template.
Important! Make sure to replace ‘page-name’ with a value unique for each page. This value will be used to retrieve comments on a page per page basis.
<div data-comments-sh-slug="page-name">
<div id="comments-sh">
</div>
<div id="form-sh">
</div>
<template id="comments-sh-comment-template">
<div class="comment">
<div>
<div><span class="comment-name"></span> says:</div>
<div class="comment-timestamp"></div>
</div>
<div class="comment-text"></div>
</div>
</template>
<template id="comments-sh-form-template">
<form id="comments-sh-form">
<input type="text" name="name" required minlength="2" maxlength="255">
<br>
<textarea name="text" required minlength="50" maxlength="5000"></textarea><br>
<div class="comments-sh-submit-box">
<div>
<label for="privacy">
<input type="checkbox" name="privacy" required value="true">
I agree to the <a href="/privacy/">privacy policy</a>
and consent to my data being processed.
</label>
</div>
<input type="submit" value="Comment">
</div>
</form>
</template>
</div>
Note: you may need to set display: none on the template tags for IE 11 compatibility
Congratulations! You should now have comments on your webpage.