Static page that uses partials

I have a single HTML page in static. I’d like this page to use the same CSS/SCSS as the other pages on my website.

Is there a way I can use partials in this static page? If not, what is the best practice for dealing with this? Do I have to resort to injecting lines with something like sed?

No.

Hard to say without knowing the details. Is there a reason you can’t treat this file as content with a unique template??

1 Like

How would I go about doing that? Since the .md page would have no content.

Let’s say I want the page to be under /foo/bar/api
then I would create

content/foo/bar/api.md

with the following content:


---
Title: API
layout: api
---

correct?

But I can’t ever get the layout to work.
I tried creating

layouts/api/single.html
layouts/foo/bar/api/single.html

but neither work

You should create a layout called api.html in the _default layouts folder.

Thank you. I think it’s picking up the HTML file now but the page I’m seeing is not what I would expect, the HTML page isn’t being shown correctly. Its different compared to what I see if I run an http-server and load the HTML page at http://127.0.0.1:8080/layouts/_default/api.html

The above is either a typographical error, or a conceptual disconnect.

The page you created is served at:
http://localhost:1313/foo/bar/api

Are you trying to open the file directly from the file system instead of serving it? If so, don’t do that.

Working example:

git clone --single-branch -b hugo-forum-topic-52479 https://github.com/jmooring/hugo-testing hugo-forum-topic-52479
cd hugo-forum-topic-52479
hugo server

There’s no error. Like I said I’m loading that page after starting an http-server (nodejs server).

Ok, so, the above isn’t a thing.

I suggest you compare what you have done with the working example that I provided.

I’m running hugo serve. The page I see is not the same page I see on the http-server.

So there’s no alternative to static pages?

Please see my previous comment.

I’ve got it working for a brand new hugo project with a recent hugo version.
In what version did hugo introduce layout targeting?

Found the issue. There was a single.html affecting how the page was being formatted.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.