2017-08-10 11:18:22 -04:00
---
title: File Variables
linktitle:
description: "You can access filesystem-related data for a content file in the `.File` variable."
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [variables and params]
2017-09-21 13:03:00 -04:00
keywords: [files]
2017-08-10 11:18:22 -04:00
draft: false
menu:
docs:
parent: "variables"
weight: 40
weight: 40
sections_weight: 40
aliases: [/variables/file-variables/]
toc: false
---
{{% note "Rendering Local Files" %}}
For information on creating shortcodes and templates that tap into Hugo's file-related feature set, see [Local File Templates ](/templates/files/ ).
{{% /note %}}
The `.File` object contains the following fields:
2017-12-30 03:15:31 -05:00
.File.Path
2017-08-10 11:18:22 -04:00
: the original relative path of the page (e.g., `content/posts/foo.en.md` )
2017-12-30 03:15:31 -05:00
.File.LogicalName
2017-08-10 11:18:22 -04:00
: the name of the content file that represents a page (e.g., `foo.en.md` )
2017-12-30 03:15:31 -05:00
.File.TranslationBaseName
2017-08-10 11:18:22 -04:00
: the filename without extension or optional language identifier (e.g., `foo` )
2017-12-30 03:15:31 -05:00
.File.BaseFileName
2017-08-10 11:18:22 -04:00
: the filename without extension (e.g., `foo.en` )
2017-12-30 03:15:31 -05:00
.File.Ext
2017-08-10 11:18:22 -04:00
: the file extension of the content file (e.g., `md` ); this can also be called using `.File.Extension` as well. Note that it is *only* the extension without `.` .
2017-12-30 03:15:31 -05:00
.File.Lang
2017-08-10 11:18:22 -04:00
: the language associated with the given file if Hugo's [Multilingual features][multilingual] are enabled (e.g., `en` )
2017-12-30 03:15:31 -05:00
.File.Dir
2017-08-10 11:18:22 -04:00
: given the path `content/posts/dir1/dir2/` , the relative directory path of the content file will be returned (e.g., `posts/dir1/dir2/` )
[Multilingual]: /content-management/multilingual/