Get raw data from external URL

Today I was trying to implement Ezoic in a project and among other things they have the need for an ads.txt file at the root of the site. No problems there, however, during the setup they require us to create an HTTP redirection and even provide examples with PHP, Nginx etc.

The farthest I managed to replicate this with Hugo was with Custom Templates and a <meta http-equiv="refresh"/> tag, but that wouldn’t output a TXT. And by using uglyUrl the output file would be a TXT but the <meta> wouldn’t work, after al, it’s a TXT.

Then I’ve found this topic and following the GitHub Issues Tracker I’ve found this issue that, apparently, would allow me to accomplish my goal using resources.Get but with the fragment provided in the last comments of said issue (I can’t repost here because of the temporary 2 links limit), results in an error:

error calling Get: CreateFile <ABSOLUTE_PATH_TO_MY_THEME_FOLDER><URL>: The filename, directory name, or volume label syntax is incorrect

So, is this implemented yet? If not, is there an alternative?

Your objective is unclear. What, specifically, do you need to create? And what is the source?

Retrieve any data from an external URL to generate an updated file with the Response obtained, like demonstrated by the fragment in the linked issue.

Use resources.GetRemote.

1 Like

Perfect! Thank you for your time :slight_smile:

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