Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snippets of content and/or creating single page sites #534

Closed
mrenoch opened this issue Oct 1, 2014 · 5 comments
Closed

snippets of content and/or creating single page sites #534

mrenoch opened this issue Oct 1, 2014 · 5 comments
Labels

Comments

@mrenoch
Copy link

mrenoch commented Oct 1, 2014

Hi,

Great project!

I am looking at hugo to generate the ever-so-fashionable single page sites, e.g. http://html5up.net/helios or http://html5up.net/tessellate.

I am trying to wrap my head around how I can create content that will be pulled into the template. Can I include content by referencing it's slug?

Am I asking the same question as the one posed here?

#247

thanks!

@jorinvo
Copy link
Contributor

jorinvo commented Oct 1, 2014

Hi @mrenoch!

#247 is about including other content in a content file using a shortcode. That's not possible right now.

Fortunately you don't need that to build a single page site.
You probably just want one big index.html file in your layouts/ directory (maybe some partials to make it easier to work with).
In this file you can render all the content you want just.
If you have a section listing some customers you could do:

{{ range where .Data.Pages "Section" "customers" }}
   {{ .Content}}
{{ end }}

If you want to render one specific content you can identify it by the relative link:

{{ range .Data.Pages }}
        {{ if eq .RelPermalink "/section/intro/" }}
        {{ end }}
   {{ .Content}}
{{ end }}

For more make sure to check the "Template" section of the docs. It explains all you need.

Hope that helps. Read the docs and feel free to ask if you have further questions!

@mrenoch
Copy link
Author

mrenoch commented Oct 2, 2014

Thanks for the rapid response.

Yes, I am trying to separate the snippets of content from the html, although at some level it's futile since the formatting seems to creep into these snippets, and the html is pretty clean and straightforward for non-programmers to edit.

Still, a shortcode to pull in a particular piece of content (by slug? or whatever), would be powerful. I suppose I can fake that with sections, with one piece of content per section, but that's pretty cumbersome.

I did read the Template section of the docs, but I still find it confusing . Perhaps a better running example would help tie this together? Maybe this already exists but I haven't found it?

Thanks.

@mrenoch mrenoch closed this as completed Oct 2, 2014
@jorinvo
Copy link
Contributor

jorinvo commented Oct 2, 2014

I have to admit that the Template section of the docs is a bit confusing and it doesn't list all variable in the moment.

But you can pull in a single content based by slug.
I tried to build a flexible shortcode.
It should allow you to just write {{% content link="/posts/first/" %}} in your markdown and render another content.
There is just a problem in the moment that in some cases the indentation gets interpreted as code and highlighted..

@mrenoch
Copy link
Author

mrenoch commented Oct 13, 2014

Hello again,

Thanks for the suggestion, but still no luck. The shortcode won't work since I am trying to include some content within the template (NOT from inside another piece of content) so I don't think shortcodes work.

The range .Data.Pages examples you provided are very confusing. What does .RelPermalink refer to? I have tried multiple organizational layouts without any luck. I am unclear if the relpermalink refers to the filename, the path, the slug or what.

On a related note, what kinds of debugging tools can I use with hugo - is there any way to step through the execution to inspect what variables are available to me? I know that Go isn't interpreted, but I am not sure how to approach making sense of the assumptions it's making.

Thanks,
/Jonah

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants