Nanopub for Hugo

(This seems iffy as a “support” topic, so please let me know if this should be moved.)

I’d like to open up a discussion on how best to set up a Hugo site with micropub and nanopub, or specifically, how to publish to a Hugo blog/site via third party service such as http://micro.blog.

The documentation on the nanopub site is fairly limited, it seems. I was able to install the service on my site, though I am using Netlify for hosting which does not allow for PHP to be run (if I’m understanding correctly.)

Another possible solution would be webpage-micropub-to-github though this is tailored for Jekyll sites and was a little confusing for me as well.

I’d really like to use my own site to post thoughts remotely using an app such as micro.blog or others, but I do understand it’s difficult with a static site generator.

Anyone else interested in exploring this and sharing our journies?

I wonder if this is relevant? :

It’s definitely partially relevant. It’s the only thing I found when searching, but only refers to the content piece, and not so much of the posting externally part, which is what I’d like to focus on in this thread.

You could do something like this in your layouts/index.html.

It will list all posts, ordered by date descending, and will only show the post content.

{{ range where .Pages.Date.Reverse "Section" "post" }}
<p>{{ .Content }}</p>
<hr>
{{ end }}

Then you could create/edit posts remotely with something like Forestry.io

1 Like

Again, focusing on the remote posting here. Formatting of microposts is another topic :slight_smile:

Forestry is a decent option, however it’s quite buggy in my experience. Do they have an app coming, does anyone know? The nice thing about something like micro.blog is that you’re instantly sharing to multiple sources with one easy app posting.

What do you mean by app?

From what I’ve seen they have a web app that is also mobile-friendly.

Sorry, specifically I mean a mobile app for iOS/Android, that is specifically made for posting. Forestry’s web app is frustratingly buggy, and I need to write each post as a “post” – a full blog post with categories, title, etc. When all I really want to do is tweet (in essence) and be done.

Does that make sense?

Gotcha. Well, I don’t have anything else to add as of now.

It makes sense.

But there is no mobile app out there that would do this for your Hugo project as simple as you want.

The closest thing, I’ve seen on mobile (and it’s only for Android) is the Termux terminal emulator.

There is even a Termux apt repo for Hugo courtesy of @holehan

I suppose that you could have a Hugo archetype in your project for your microposts, so that all necessary front matter is generated automatically.

Then execute the command hugo new "/posts/some.md" from your phone. Open that file with your favorite Android markdown editor and just write what you want.

You would also need an Android git client, so that once you save your micropost, you could then push to your repo and trigger a build.

1 Like

There is an app, it’s called micro.blog :slight_smile:

However, as I mentioned in my first post, it requires use of micropub standards and libraries like nanopub, as demonstrated by https://ascraeus.org.

And https://github.com/voxpelli/webpage-micropub-to-github which works with Jekyll and connects to Github to push in the content.

The mobile app aspect is mainly to post content to your micropub endpoint easily via an established UI. micro.blog is merely an example of something that will do that.

I wrote my own micropub endpoint for use with Hugo, too: https://github.com/skpy/micropub It does use PHP. I don’t use Fastly, so I can’t provide much help there.

I use Quill to post to my site most of the time: https://quill.p3k.io. There’s also Indigenous as a dedicated mobile client, as well as a few others.

If you’re going really micro (i.e., < 300 characters), I’d put it in a Google Sheet and use IFTT or Zapier to automate all of it (e.g. using a webhook with something like Netlify) and push to Twitter, etc. You could probably do this with O365 and MS Flow too, or even start the workflow in Twitter and work backwards.

Then you have a mobile app to use, a single source for COPE (create once, publish everywhere), and the benefit of treating all your “posts” as serialized data for uber-easy export to whatever you want in the future (i.e. if you start with a spreadsheet). You also don’t have to worry about individual markdown files, which would be a royal PITA for something as simple as microblogging/Tweeting.

Win-win-win.

1 Like

Good ideas.

I do want to maintain this set of requirements:

  • Own my content (maintain content under my domain)
  • Keep markdown files for individual permalinks as needed
  • Post using microformats such as micropub, if possible

I’m looking into IFTT as an easy way to grab my few lines of text and publish them to Github.

Gotcha, but real “permalinks” require individual URLs/pages, not hashes, IMHO, if the idea is to keep them as individual markdown files rather than just a list of links on a single page. (My fault for misunderstanding this requirement from you.)

What I was thinking with Google Sheet is that you can have Sheets publish a spreadsheet to a long, publicly available CSV every time you make a change. Then have IFTT also watch for that change and post to a webhook (this is easy enough with Zapier as well), which would trigger a Hugo build that pulls from getCSV. This is simple to do out of the box with Netlify too, btw.

But if you want the individual markdown files, I guess my rec was a little misguided :smile:

1 Like

Hi,

Author of nanopub here.

I’m afraid I don’t have any experience of netlify at all, however, so I’m not sure what assistance I can be.

In respect of documentation, I admit that I haven’t gotten any feedback in relation to deficiencies, but would be happy to take any criticisms. The documentation as it stands is certainly written from the point of view of deploying on a VPS, rather than using a system such as netlify. I guess you could run nanopub as an endpoint on a separate server, feeding the finalised document into something like netlify, but then why use netlify at all?

The set of requirements which you state are the ones which I had in mind when I wrote nanopub, and, as you point out, I use it on my own site with Hugo.

I’m sorry if this post seems elliptical, but please do make contact if you have queries or advice in relation to the documentation, and I’d be happy to assist in any way with the program.

Oh, looping back to Hugo, I can also provide details of the methods I use in relation to post structure, hit me up for details :slight_smile:


dgold

3 Likes

Netlify cannot run PHP on its server. It allows only static pages.

Thank you for replying here! I apologize if my initial post(s) felt critical of your nanopub documentation. I mostly meant that the docs were limited as far as my own use, and I should edit the above to reflect that. It seems my implementation at Netlify is limiting my feature set, so I will likely reevaluate that. I am using Netlify mostly because of their tight integration with Hugo and easy build hooks.

I will certainly get in touch with you if I have more specific questions. Thanks again!