Can I get the current page URL in a widget?

If possible, I need to get the current page URL in a widget so I can correctly create social media icons for sharing articles.

.RelPermalink and .Page.RelPermalink return null in that context. I haven’t been able to find another solution.

Is it possible?

Thanks so much! :slight_smile:

What’s a “widget”?

1 Like

Ah, sorry, I assumed that the feature in this theme was more common.

In this theme, single.html includes the html file partials/sidebar.html. Sidebar.html includes a number of small html files, one of which is called widgets/social.html.

When attempting to use .RelPermalink and .Page.RelPermalink in social.html, they return null values.

Thanks! :slight_smile:

Basically, It feels like the page context is not accessible from social.html.

Which theme?

How is it called?

{{ partial "widgets/social.html" }} OR
{{ partial "widgets/social.html" . }} OR

something completely different?

Once again, you have solved my problem in no time at all.

I was not aware of the . for passing contexts. Thank you, thank you, thank you!



This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.