gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.86k stars 7.54k forks source link

Support ActivityPub #8135

Closed gavinr closed 1 year ago

gavinr commented 3 years ago

Is it possible for Hugo to support ActivityPub? This is important because it allows someone to subscribe to your Hugo blog via Mastodon/Frendica/Pixelfed/etc.

It looks like a WordPress plugin supports this for WordPress blogs: https://wordpress.org/plugins/activitypub/

I found this prior-art of someone trying to implement in Hugo: https://jlelse.blog/dev/activitystreams-hugo ... that user links here, which seems to be a good resource.

  1. Is this possible?
  2. Would it make sense to be included with Hugo? (probably could use how RSS works in Hugo as inspiration)

Relevant discussion: https://github.com/w3c/activitypub/issues/310#issuecomment-404348290

ghost commented 3 years ago

whuld be cool

freemo commented 3 years ago

It already does (with a little tweaking).. see the following:

https://codeberg.org/jlelse/hugo-activitystreams

https://jlelse.blog/dev/activitystreams-hugo

Thorgrimson commented 2 years ago

@freemo can you explain the ressources a little bit more; i tried to figured out myself but i failed; but shure how to debug. First Problem is that I do not know where to get my public key for publickeypem?

drupol commented 2 years ago

Sadly this is abandonware.

Can you please elaborate?

mgladdish commented 1 year ago

With the post-twitter Mastodon explosion, this is newly relevant. Would be great to see this working.

nileshtrivedi commented 1 year ago

Two posts I came across that may be relevant:

rothgar commented 1 year ago

Two posts I came across that may be relevant:

I'm the author of this post and here's what I learned when researching this topic. My end goal is to make my hugo blog publish posts on mastodon, but it won't work with only static files.

Mastodon requires active server components for /inbox and /outbox. These endpoints need to dynamically accept URL parameters and send requests to other servers.

Right now I'm planning to implement /inbox as a lambda function. It will accept follow requests (and send follow acknowledgements) and store followers in a database or file objects (eg s3). It also needs to handle unfollow requests.

The outbox can be a static file but mastodon will not fetch old posts from an outbox, all posts must be sent to a followers inbox (mastodon does cache outbox items per server). My plan is to implement the outbox as a static file and have all outgoing requests handled during build time. For example, I will have a CLI that will build the outbox file after hugo renders the site and then look up all of the followers and send the appropriate POST requests to their inbox.

This would be an almost static mastodon server. Hugo won't be able to do everything because of the way activitystream/mastodon works. It would be nice to integrate the activitystream templates that were posted earlier so I could automatically render the /outbox file and each individual post item.

gavinr commented 1 year ago

Thank you @rothgar.

Mastodon requires active server components for /inbox and /outbox. These endpoints need to dynamically accept URL parameters and send requests to other servers.

That explains it quite well - Hugo cannot natively support this. Unless I'm missing something (@bep?), Hugo cannot support this type of active server push/pull, and so I will close this issue.

nileshtrivedi commented 1 year ago

@rothgar Would it make sense to patch Mastodon so that IF there's no inbox (i.e. feed publisher cannot accept follow requests and therefore cannot PUSH new posts), THEN Mastodon switches to periodic pull for the outbox like a regular RSS feed reader? This might then make it possible for a static site to have a feed in Mastodon, albeit with the compromise that new posts will not be fetched in real-time and there would be a small delay same as any feed reader.

rothgar commented 1 year ago

You would have to update the ActivityPub protocol to support static file hosting and then get Mastodon to support the new protocol. My guess is that would take at minimum 3 years (Activity Streams 2.0 came out in 2017).

There have been other people who have been asking for static file support from Mastodon and alternatives to building social media on top of static RSS files but neither of those have anything to do with hugo.

I posted on the ActivityPub forums where I can propose an official update to the protocol to support static files. We'll see where that goes.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.