# Include-file shortcode for including files with shortcode calls

**URL:** <https://discourse.gohugo.io/t/include-file-shortcode-for-including-files-with-shortcode-calls/16699>\
**Category:** tips & tricks\
**Created:** [January 28, 2019, 11:40pm UTC](https://discourse.gohugo.io/t/include-file-shortcode-for-including-files-with-shortcode-calls/16699 "2019-01-28T23:40:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharonl](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sharonl/32/3236_2.png) [@sharonl](https://discourse.gohugo.io/u/sharonl)\
**Post date:** [January 28, 2019, 11:40pm UTC](https://discourse.gohugo.io/t/include-file-shortcode-for-including-files-with-shortcode-calls/16699/1 "2019-01-28T23:40:08Z")

</div>

Following is a simplified version of our `include` shortcode for including Markdown (or HTML) content files from other content files:

**include.html**

```auto
{{- $includes_dir := (.Get "d") | default .Site.Params.includes_dir -}}
{{- $include_file := printf "%s/%s" $includes_dir (.Get "f") -}}

{{- with .Site.GetPage $include_file -}}
  {{- .Content | markdownify -}}
{{- end -}}

```

In **config.toml** , we set an `includes_dir` site `Params` variable to a default includes content directory:

```auto
[Params]
  includes_dir = "_includes"

```

**NOTES**

- With **`readFile`** (as opposed to `getPage`), shortcode calls in the included file aren’t processed.  
Also, `readFile` accepts a file path within the Hugo root directory while `GetPage` accepts a relative file path within the configured content directory.

- **PROBLEM:** Initially, **adding a shortcode call at the start of the included file** (before any text or standard Markdown code) **produced a Hugo runtime error** :

- For information about **include-file shortcode-calls context issues** that we encountered and our solution (related to our multi-version site design), see [Include-file shortcode context issues](https://discourse.gohugo.io/t/include-file-shortcode-context-issues/16664).

- For **reflecting include-file headings in the including file’s page mini TOC** , see my answer on the [Shortcode processing order](https://discourse.gohugo.io/t/shortcode-processing-order/16554/) thread and the  
[Shortcode processing order - #8 by sharonl](https://discourse.gohugo.io/t/shortcode-processing-order/16554/8) tips post that it references.
