diff --git a/content/templates/introduction.md b/content/templates/introduction.md index 0f4e8e3d3..d10cc03a0 100644 --- a/content/templates/introduction.md +++ b/content/templates/introduction.md @@ -109,24 +109,37 @@ There are more boolean operators than those listed in the Hugo docs in the [Gola ## Includes -When including another template, you will pass to it the data it will be -able to access. To pass along the current context, please remember to -include a trailing dot. The templates location will always be starting at -the `/layouts/` directory within Hugo. +When including another template, you will need to pass it the data that it would +need to access. -### Template and Partial Examples +{{% note %}} +To pass along the current context, please remember to include a trailing **dot**. +{{% /note %}} -``` -{{ template "partials/header.html" . }} -``` +The templates location will always be starting at the `layouts/` directory +within Hugo. -Starting with Hugo v0.12, you may also use the `partial` call -for [partial templates][partials]: +### Partial + +The [`partial`][partials] function is used to include *partial* templates using +the syntax `{{ partial "/." . }}`. + +Example: ``` {{ partial "header.html" . }} ``` +### Template + +The `template` function was used to include *partial* templates in much older +Hugo versions. Now it is still useful for calling [*internal* +templates][internal_templates]: + +``` +{{ template "_internal/opengraph.html" . }} +``` + ## Logic Go templates provide the most basic iteration and conditional logic. @@ -479,6 +492,7 @@ Go allows you to do more than what's shown here. Using Hugo's [`where` function] [index]: /functions/index/ [math functions]: /functions/math/ [partials]: /templates/partials/ "Link to the partial templates page inside of the templating section of the Hugo docs" +[internal_templates]: /templates/internal/ [relpermalink]: /variables/page/ [safehtml]: /functions/safehtml/ [sitevars]: /variables/site/ diff --git a/content/templates/partials.md b/content/templates/partials.md index 0d2a9f479..4cb7fb3a5 100644 --- a/content/templates/partials.md +++ b/content/templates/partials.md @@ -67,10 +67,6 @@ As shown in the above example directory structure, you can nest your directories {{ partial "footer/scripts.html" . }} ``` -{{% note %}} -Before v0.12, Hugo used the `template` call to include partial templates. When using Hugo v0.12 and newer, be sure to use the `{{ partial "/.html" . }}` syntax. The old approach will still work but has fewer benefits. -{{% /note %}} - ### Variable Scoping The second argument in a partial call is the variable being passed down. The above examples are passing the `.`, which tells the template receiving the partial to apply the current [context][context]. @@ -166,4 +162,4 @@ The following `footer.html` partial template is used for [spf13.com](http://spf1 [lookup order]: /templates/lookup-order/ "To keep your templating dry, read the documentation on Hugo's lookup order." [partialcached]: /functions/partialcached/ "Use the partial cached function to improve build times in cases where Hugo can cache partials that don't need to be rendered with every page." [singletemps]: /templates/single-page-templates/ "The most common form of template in Hugo is the single content template. Read the docs on how to create templates for individual pages." -[themes]: /themes/ \ No newline at end of file +[themes]: /themes/