Best way to "federate" static HTML with Hugo HTML


#1

Couldn’t find exactly what I’m looking for, so I’ll make a new post (with my apologies).

I’m generating static HTML from Swagger/OAS REST API spec files. I want to be able to link to the files from the static HTML I generate in Hugo.

Is there a good way to put the REST API HTML into the Hugo site? I’d like create a shortcode that links to a REST API HTML page or some part of it. I’ve tried putting the REST HTML into /static or /content, but I haven’t been able to create a shortcode that “finds” the REST HTML correctly and constructs a link.


#2

We’d have to see your project to better assist.

But just for example, let’s say your static HTML sits at static/some-page.html

Then you could link to this directly in your content:

<a href="/some-page.html">Link Text</a>

#3

Do you mean <site-root>/static/some-page.html? If I prefer to put the HTML in <site-root>static/api-html, will
<a href="/static/api-html/some-page.html">Link Text</a> also work?


#4

Test it and let us know :slight_smile:

You’ll need to update your href – remember that everything in static/ gets copied to the root of your site

<a href="/api-html/some-page.html">Link Text</a>