# Partials with Markdown content

**URL:** <https://discourse.gohugo.io/t/partials-with-markdown-content/6733>\
**Category:** support\
**Created:** [May 26, 2017, 5:36pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733 "2017-05-26T17:36:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Netross](https://avatars.discourse-cdn.com/v4/letter/n/c0e974/32.png) [@Netross](https://discourse.gohugo.io/u/Netross)\
**Post date:** [May 26, 2017, 5:36pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/1 "2017-05-26T17:36:53Z")

</div>

I am working on converting my companies website over to be done in hugo, but unfortunately the best way to maintain my layout is by using lots of partial templates to essentially give the website a ‘block’ style layout. I am creating a new theme to do this but I am running into an issue where I will have to have basically an end user changing the markdown content of the website as the website needs updates. Well the bulk of this content is contained inside a various partial templates. Is there a way to have a partial template use an it’s own markdown file? Sorry if I have poorly explained this, I can try to elaborate better if needed.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [May 26, 2017, 5:55pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/2 "2017-05-26T17:55:03Z")

</div>

- If this is markdown file not also present as content pages, you _could_ use the `readFile "myfile.md" | markdownify` – but I would then recommend using the `partialCached` func.
- If this is existing pages, I have just updated (i.e. not released yet) the `GetPage` func to also handle regular pages, so in the next Hugo (or the current development version), you could do `{{ (.Site.GetPage “blog/funny-post.md”).Content }}``
- Then there is also the `/data` files, which also can be sent into the `markdownify` func.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [May 26, 2017, 5:55pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/3 "2017-05-26T17:55:47Z")

</div>

Unfortunately no. There is no way to use a partial in a content file. I understand what you’re trying to achieve though. And I am currently in a similar situation as you.

EDiT  
The above answer by @bep looks interesting. I wasn’t aware of the readFile function.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [May 26, 2017, 6:04pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/4 "2017-05-26T18:04:38Z")

</div>

> [@alexandros](#):
>
> The above answer by @bep looks interesting. I wasn’t aware of the readFile function.

I will note it one more time, because it is important, the `readFile` has no caching whatsoever, so if you include it in the `single.html` template on a site with 10,000 pages, that same file will be read 10,000 times, so use `partialCached`.

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [May 26, 2017, 7:48pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/5 "2017-05-26T19:48:15Z")

</div>

If you want include one content file in another [mmark](https://github.com/miekg/mmark/wiki/Syntax#including-files) support this feature.

---

<div class="post-metadata">

**Author:** ![budparr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/budparr/32/749_2.png) [@budparr](https://discourse.gohugo.io/u/budparr)\
**Post date:** [May 27, 2017, 1:32pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/6 "2017-05-27T13:32:39Z")

</div>

@Netross I’d be interested to hear more about what you’re trying to accomplish with box layouts. Do you have a repo to share, a spec, or a mockup so I can get a better sense of it? It’s something that should be fairly straightforward in Hugo.

---

<div class="post-metadata">

**Author:** ![Netross](https://avatars.discourse-cdn.com/v4/letter/n/c0e974/32.png) [@Netross](https://discourse.gohugo.io/u/Netross)\
**Post date:** [May 27, 2017, 5:53pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/7 "2017-05-27T17:53:39Z")

</div>

@bep I will have to look into the partialCached function more, but I am very interested in the GetPage function that is un-released.  
@budparr I unfortunately cannot share the repo with anyone, but to better describe the ‘block’ content, think of a one page style website where they have separate sections of the same page all for different information. Well for our website almost every page is like that, but it is a large website and on every page each section is different than the next, and all of that content needs to be able to be changed by a markdown file. If I were able (which I may be) to make each section (or block) a partial template attached to a markdown file, that would be the easiest way to achieve the end goal I am after. I will explore my options with the suggestions that @bep made and see what I can do.  
I am also very new to hugo so that has a lot to do with the struggle I am having as well.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [May 27, 2017, 6:32pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/8 "2017-05-27T18:32:50Z")

</div>

A note on the unreleased remark: The Hugo master branch has proven to be very stable, so if you really need an unreleased feature, getting a development version would be a good way. Either by compiling one yourself, or I believe you could also get one via Brew on macOs.

---

<div class="post-metadata">

**Author:** ![budparr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/budparr/32/749_2.png) [@budparr](https://discourse.gohugo.io/u/budparr)\
**Post date:** [May 27, 2017, 7:12pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/9 "2017-05-27T19:12:00Z")

</div>

Okay, so I’m not sure if this is helpful, but, consider this content, where you can boxed content of a sort listed in front matter (you can get quite elaborate with front matter, by the way):

> <https://github.com/budparr/gohugo.io/blob/master/content/_index.md>

That “features” section is rendered in this partial:

> <https://github.com/gohugoio/gohugoioTheme/blob/master/layouts/partials/home-page-sections/features-icons.html>

I have a more elaborate example with much more content, but I wrote that one a while back (I’m still relatively new to Hugo and learning, myself), but suffice to say, it sounds like what you’re trying to do can be done quite efficiently with Hugo.

Hope that’s helpful!

---

<div class="post-metadata">

**Author:** ![DaveParr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/daveparr/32/6489_2.png) [@DaveParr](https://discourse.gohugo.io/u/DaveParr)\
**Post date:** [October 23, 2018, 3:10pm UTC](https://discourse.gohugo.io/t/partials-with-markdown-content/6733/10 "2018-10-23T15:10:41Z")

</div>

I’m looking into this myself, and it appears that there is, used in the universal theme.

The [contact.md](https://github.com/devcows/hugo-universal-theme/blob/master/exampleSite/content/contact.md) file has it’s `yaml` like so:

```auto
+++
title = "Contact" 
id = "contact" 
+++

```

The `id = "contact"` line seems to be referring [to this partial ‘contact.html’](https://github.com/devcows/hugo-universal-theme/blob/master/layouts/partials/contact.html). You can see that it is supplying not only the [`contact.html` partial](https://github.com/devcows/hugo-universal-theme/blob/master/layouts/partials/contact.html) with the formspree contact form, but also plumbed into another [partial `map.html`](https://github.com/devcows/hugo-universal-theme/blob/master/layouts/partials/map.html) which itself is displaying the JavaScript output of the  
[`gmaps.init.js` file](https://github.com/devcows/hugo-universal-theme/blob/master/static/js/gmaps.init.js).
