Partial Templates | Hugo - Static Site Generator | Tutorial 21

Поделиться
HTML-код
  • Опубликовано: 27 дек 2024

Комментарии • 16

  • @brittanylindgren1656
    @brittanylindgren1656 3 года назад +2

    I'm really enjoying these tutorials. Great explanations, you cover everything I need to know to have a good foundation and the length of the videos is manageable. The only thing is that the quick zoom-in zoom-out to look at items on the page is making me feel a bit nauseous, just fyi. Everything else is great :D

  • @kent8547
    @kent8547 3 года назад +5

    What's the difference between partials and the block templates that you described in an earlier video?

  • @craigthomas7813
    @craigthomas7813 6 лет назад +1

    what's an example of a good use case for dictionaries? the usage here doesn't seem very flexible (unless there's more to it and I'm missing something, which might be the case)

  • @DavidS-dw1wv
    @DavidS-dw1wv 2 года назад +2

    If anyone can clarify when to use blocks (as in the previous baseof.html video) and when to use partials (as in this video) that would be super helpful. Thank you.

    • @xphis0528
      @xphis0528 Год назад

      yes, I see some ambiguity and overlapping sometimes using Hugo, for example here.

    • @devbthom
      @devbthom Год назад +1

      It seems like blocks are more for the shell of the page and partials are snippets are for injecting into those pages.

  • @noblenetdk
    @noblenetdk 2 года назад

    How do you choose a theme? which criterias do you use?

    • @wakegary
      @wakegary 3 месяца назад

      how does one feel a kiss?

  • @alexanderwolf3858
    @alexanderwolf3858 7 лет назад

    Your tutorials are great. I really enjoy watching them. Keep up the good work. One question to partials - How can I use default values inside the partial? E.g. if someone haven't passed myTitle to the partial how can I set a default value inside of the partial. I've tried {{ .myTitle | default "Dummy title" }} but that's not working. Error Msg. can't evaluate field myTitle in type *hugolib.PageOutput

    • @GiraffeAcademy
      @GiraffeAcademy  7 лет назад

      Hey Alexander, good question!
      You wanna use an if statement to check whether or not a title has been passed into the partial. You could do something like this:
      {{ if .myTitle }}{{ .myTitle }}{{ else }} default value {{ end }}
      This checks to see if the .myTitle variable has a value and if it does then it uses that value, otherwise it uses the default value
      Thanks for the comment!

    • @alexanderwolf3858
      @alexanderwolf3858 7 лет назад

      Thanks for the advice. I did more tests - your solution and mine with default will only work if I'm passing a dictionary to the partial function.
      If I'm using {{ partial "header" . }} it won't work. I debugged the scope inside of the partial a bit but I still don't know how to solve this. Debugging with printf to show the context as described [here](gohugo.io/templates/template-debugging/).
      If dictionary is passed I'm having something like
      map[string]interface {}{ "myTitle": "Title"}
      with just the scope passed to the partial it looks like
      &hugolib.PageOutput{Page:(*hugolib.Page)(0xc043782500), ... }
      The best result to the issue is if i'm passing the context in a dict - probably not the best solution but it is working:
      {{ partial "header" (dict "context" .) }}

    • @CameronPak
      @CameronPak 6 лет назад

      Hello, it kind of looks like you were trying to use a language called Liquid from Shopify when you said {{ .myTitle | default "Dummy title" }}. I'm happy he helped you below!

  • @IanMcQuay
    @IanMcQuay Год назад

    I know the first word is Giraffe but you say it way too fast. I think you should say it slower. Jekyll is easier to learn.

  • @ventzpetkov
    @ventzpetkov 6 лет назад

    Please curb the zooming in and out. It makes it harder to follow/listen, and it gets annoying very quickly. Also, it's just unnecessary -- your default zoom is perfect, and it looks great at both the "normal" screen size (not embedded) and full screen. Other than that, excellent content - thank you!

    • @jason.vasilev
      @jason.vasilev 5 лет назад +4

      Somehow I can't watch the video in HD, and zooming really helps me see what he types. I find it useful