# Question about {{ printf "%#v" . }}

**URL:** <https://discourse.gohugo.io/t/question-about-printf-v/22923>\
**Category:** support\
**Created:** [January 21, 2020, 3:39am UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923 "2020-01-21T03:39:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bix](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bix/32/9674_2.png) [@bix](https://discourse.gohugo.io/u/bix)\
**Post date:** [January 21, 2020, 3:39am UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923/1 "2020-01-21T03:39:11Z")

</div>

(Note: This is about Hugo variables, but on a hosted blogging site I do not have access to except as a user. I’m hoping this particular question has enough of a hook into the general case that the specifics of that blog system won’t matter, but you never know.)

The output of the above on, e.g. a photos page, is:

```
&
hugolib.PageOutput {
    Page: ( * hugolib.Page)(0xc000d22000),
    paginator: ( * hugolib.Pager)(0xc000b5cc00),
    paginatorInit: sync.Once {
        m: sync.Mutex {
            state: 0,
            sema: 0x0
        },
        done: 0x0
    },
    resources: resource.Resources {},
    resourcesInit: sync.Once {
        m: sync.Mutex {
            state: 0,
            sema: 0x0
        },
        done: 0x1
    },
    targetPathDescriptor: hugolib.targetPathDescriptor {
        PathSpec: ( * helpers.PathSpec)(0xc0004a1380),
        Type: output.Format {
            Name: "photoshtml",
            MediaType: media.Type {
                MainType: "text",
                SubType: "html",
                mimeSuffix: "",
                Delimiter: ".",
                Suffixes: [] string {
                    "html"
                },
                fileSuffix: ""
            },
            Path: "photos",
            BaseName: "index",
            Rel: "alternate",
            Protocol: "",
            IsPlainText: false,
            IsHTML: false,
            NoUgly: false,
            NotAlternative: true
        },
        Kind: "home",
        Sections: [] string(nil),
        BaseName: "",
        Dir: "",
        LangPrefix: "",
        IsMultihost: false,
        URL: "",
        Addends: "",
        ExpandedPermalink: "",
        UglyURLs: false
    },
    outputFormat: output.Format {
        Name: "photoshtml",
        MediaType: media.Type {
            MainType: "text",
            SubType: "html",
            mimeSuffix: "",
            Delimiter: ".",
            Suffixes: [] string {
                "html"
            },
            fileSuffix: ""
        },
        Path: "photos",
        BaseName: "index",
        Rel: "alternate",
        Protocol: "",
        IsPlainText: false,
        IsHTML: false,
        NoUgly: false,
        NotAlternative: true
    }

}

```

Is there no way to grab that `Path”photos"` for use in an `if eq`?

(The system in question is still on 0.53 and is working toward upgrade.)

Thanks.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [January 21, 2020, 6:22am UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923/2 "2020-01-21T06:22:48Z")

</div>

Hi there,

Have a look at [Page Variables](https://gohugo.io/variables/page/). Perhaps `.Dir` or other `.File` [variables](https://gohugo.io/variables/files/) might be helpful.

---

<div class="post-metadata">

**Author:** ![bix](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bix/32/9674_2.png) [@bix](https://discourse.gohugo.io/u/bix)\
**Post date:** [January 21, 2020, 3:40pm UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923/3 "2020-01-21T15:40:21Z")

</div>

Thanks but alas no, none of the typical variables work because both pages are considered “home” and so there’s no specific hooks to “photos” or “archives” to grab. (That’s why I’m asking about the info that the debugging template tag _does_ produce but I can’t seem to figure out how to actually make use of.)

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [January 21, 2020, 5:11pm UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923/4 "2020-01-21T17:11:03Z")

</div>

it seems what you call a “photos page” is a Custom Output Format isn’t it?

If so, unfortunately there is currently no way to test for the “current” output format.

What I do though is use `.AlternateOutputFormats` and `OutputFormats` and check what’s left.

This is the returning partial I use, I’m sure it could be improved (you should replace: `$outputs` with your own.

```auto
{{/*
  GetCurrentOutput
  Retrieves the OuputFormat of the page, from a list of predefined outputs  
  
  @author @regisphilibert

  @context Page (.)

  @access public

  @return A String among the predefined list

  @example - Go Template
    {{ $currentOutputFormat := partial "func/GetCurrentOutput" . }}

  @warning This partial cannot be cached.
*/}}

{{/* We create a slice listing the concerned output formats */}}
{{ $outputs := slice "default" "ug1" "ug2" }}
{{ $alt := slice }}
{{/* We range on the page's Alternative Output Formats which returns all output formats
except the current one. */}}
{{ range .AlternativeOutputFormats }}
{{/* If an output format matches one in the concerned list, we add it to our slice of outputs */}}
  {{ if in $outputs .Name }}
    {{ $alt = $alt | append .Name }}
  {{ end }}
{{ end }}
{{ $current := "default" }}
{{/* If any alternate output formats part of the "concerned" ones have been found, we range on them. */}}
{{ with $alt }}
  {{ range $outputs }}
    {{/* If the output format is not listed as an "alternate", it means it is the current one. */}}
    {{ if not (in $alt .) }}
      {{ $current = . }}
    {{ end }}
  {{ end }}
{{ end }}

{{ return $current }}

```

---

<div class="post-metadata">

**Author:** ![bix](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bix/32/9674_2.png) [@bix](https://discourse.gohugo.io/u/bix)\
**Post date:** [January 21, 2020, 6:45pm UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923/5 "2020-01-21T18:45:00Z")

</div>

Thanks. It will take me awhile to understand that (I’m not by any means a programmer, but typically if I spend some time I can follow the _story_ of a piece of code and that often suffices), but just for my own clarity in the meantime: can someone explain _why_ you can see what I considered in the original post to be the “relevant” bit of data when doing the `printf "%#v" .` but can’t actually call upon that bit of data in template tags themselves?

Thanks.

---

<div class="post-metadata">

**Author:** ![bix](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bix/32/9674_2.png) [@bix](https://discourse.gohugo.io/u/bix)\
**Post date:** [January 27, 2020, 12:21am UTC](https://discourse.gohugo.io/t/question-about-printf-v/22923/6 "2020-01-27T00:21:12Z")

</div>

FWIW, I ended up doing an end run around Hugo and simply output that `printf` to a hidden `<span>` and then used JavaScript to use that string to make css selectors which let me hide unwanted content on those pages. 🤷‍♂️
