Open polar9527 opened 5 years ago
Disqus 是可行的喔,我的Blog就有加入Disqus評論了。
Hi, this is the maintainer of @staticmanlab, a public GitLab instance of Staicman. Here's some shortcomings of the commenting systems mentioned above.
You may avoid these problems by switching to Staticman, which makes use of GitHub/GitLab Pull/Merge Requests instead of issues. Under Staticman's model, static comments are YML/JSON files stored in the remote GitHub/GitLab repo (usually under data/comments, configurable through the path parameter in root-level staticman.yml), and through a static blog generator (Jekyll/Hugo/etc), the stored data are rendered as part of the content. This gives a total ownership of a static site's comments.
@VincentTam Wow, that's great! Do you have any plan to add it to this theme?
@zxdawn Not for now, but you may try porting from the diff between the Hugo theme Huginn: https://framagit.org/staticman-gitlab-pages/huginn/compare/e03609e8...4a9a46dc
Bascially, you just need to adjust the HTML form field names so that they match those of staticman.yml
, and customize the CSS according to your theme.
@VincentTam Thank you for your advice! I found this tutorial which you commented below.
I tried to apply it to AllinOne
:
Add staticman.yml
.
Add these to the [params] part of config.toml
:
#Add staticman API URL to enable staticman comments
staticman_api = "https://api.staticman.net/v2/entry/dancwilliams/networkhobo/master/comments"
Add these after <!-- /.Prev & Next -->
in layouts/_default/single.html
:
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if (.Site.Params.staticman_api) }}
{{ partial "post-comments" . }}
{{ end }}
{{ end }}
Add layouts/partials/post-comments.html
, layouts/partials/comment-replies.html
and layouts/partials/comment_form.html
as same as that tutorial.
Then I got this error when rebuilding the site:
ERROR 2019/07/08 22:12:06 Error while rendering "page" in "blog/": template: _default/single.html:77:11: executing "main" at <partial "post-commen...>: error calling partial: template: partials/post-comments.html:7:33: executing "partials/post-comments.html" at <index $.Site.Data.co...>: error calling index: index of untyped nil
ERROR 2019/07/08 22:12:06 Error while rendering "page" in "sci-tech/": template: _default/single.html:77:11: executing "main" at <partial "post-commen...>: error calling partial: template: partials/post-comments.html:7:33: executing "partials/post-comments.html" at <index $.Site.Data.co...>: error calling index: index of untyped nil
Total in 27 ms
ERROR 2019/07/08 22:12:06 Failed to rebuild site: logged 2 error(s)
@zxdawn Thanks for trying. Honestly speaking, I've no idea why such error occurs. From the error message, you may focus on layouts/partials/post-comments.html
, which renders the static comments in data/comments
. I know that that folder is non-existent in your repo, but that shouldn't cause an error. I'm not an expert in Hugo, so I can't tell you why. However, my template code in the link in my previous comment works, as you can see from the demo page for the theme: https://framagit.org/staticman-gitlab-pages/huginn.
:information_source: Note that Staticman v3 is already available. Since it's under active development, many users have reported in the app's GitHub issues. It's a distributed commenting system, meaning that everyone may run his/her own API instance, which might adopt some of the unmerged PR's. To get you started in minutes, I'm reusing my comment template.
:information_source: The following lines in your root-level site config file is responsible for comment support.
:frowning: I'm not familiar with the actual procedures with FB comments. On my old GitHub pages + Octopress site, i used Disqus, but URL refactoring can lead to disappearance of comments. Changing the URL is complicated. Having LaTeX inside comments is impossible... Users don't own their comments.
:globe_with_meridians: Static comments on my current Hugo + Staticman + KaTeX GitLab pages:
Staticman comment reply
Staticman comments with the theme Beautiful Hugo provided by halogenica/beautifulhugo#222
:bulb: What does "owning my comments" mean? You can do whatever you want with it.
Staticman + KaTeX + Beautiful Hugo
:1234: Static comments are treated like the site's static content, so you can use KaTeX for math display.
:heavy_check_mark: I ported others Staticman integration code to some Jekyll and Hugo templates.
:email: Please don't hesitate to ping me on GitHub/GitLab/leave a comment on my blog/send me an email to ask for help.
:muscle: Staticman's job is to get HTML form data to the GitHub/GitLab repo, and it won't care whether GitHub/GitLab Pages are used or not.
Plz set up your own Staticman instance ! For a guide, you may see https://github.com/pacollins/hugo-future-imperfect-slim/wiki/staticman.yml, which is inspired from https://hajekj.net/2020/04/15/staticman-setup-in-app-service/.
比如 Gitment Disqus LiveRe