Coder Social home page Coder Social logo

Comments (6)

xianmin avatar xianmin commented on June 8, 2024

The {{define "content"}} {{end}} is important. You could check layouts/_default/baseof.html :

{{ block "content" . }}{{ end }}

Your {{define "content"}} {{end}} code block in your /layouts/micro/list.html will substitute {{ block "content" . }}{{ end }} in baseof.html.

So, example, create a file /layouts/micro/list.html in your site. (/layouts/_default/list.html is not need).

Code structure like this:

<!-- /layout/micro/list.html -->
{{ define "content" }}
  <section id="posts" class="posts">
    <!-- Ranges through content/micro/*.md -->
    {{ range .Data.Pages }}
      <article class="post bg-white">
        <div class="post-content">
          {{ .Content }}
        </div>
      </article>
    {{ end }}
  </section>
{{ end }}

You could try. If this is possible, in your site, the link localhost:1313/micro/ should work.

Useful link: Lists of Content in Hugo | Hugo

from hugo-theme-jane.

xianmin avatar xianmin commented on June 8, 2024

By the way, if you need Paginate, you could check layouts/index.html

from hugo-theme-jane.

jackbaty avatar jackbaty commented on June 8, 2024

Thanks for this. Using /layouts/micro/list.html renders a blank page. Nothing inside {{ define "content" }} is output.

I appreciate your help. I should probably stop bothering you with hugo-specific questions like thisk as I doubt this is a problem specific to your theme.

from hugo-theme-jane.

xianmin avatar xianmin commented on June 8, 2024

Try /layouts/micro/section.html ?
Section Page Templates | Hugo

from hugo-theme-jane.

jackbaty avatar jackbaty commented on June 8, 2024

Nothing I tried in /layouts made any difference. Still blank pages. I found this thread which suggested that html comments outside of the block could cause rendering to fail. Sure enough, I removed the comments from your example and "micro" posts are now rendering via /layouts/micro/section.html

So this works...

{{ define "content" }}
  <section id="posts" class="posts">
    {{ range .Data.Pages }}
      <article class="post bg-white">
        <div class="post-content">
          {{ .Content }}
        </div>
      </article>
    {{ end }}
  </section>
{{ end }}

But this doesn't...

<!-- comment -->
{{ define "content" }}
  <section id="posts" class="posts">
    {{ range .Data.Pages }}
      <article class="post bg-white">
        <div class="post-content">
          {{ .Content }}
        </div>
      </article>
    {{ end }}
  </section>
{{ end }}

Very strange, but ¯\_(ツ)_/¯ (Hugo v0.40.3

Thanks so much for the help.

from hugo-theme-jane.

xianmin avatar xianmin commented on June 8, 2024

This is a good news. 😄

from hugo-theme-jane.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.