Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate txt & xml files in nuxt SSR?

Tags:

vue.js

nuxt.js

Is there any way of generating a Google : ads.txt file every time i build my SSR project?

There is a module called: sitemap-module from nuxt-community, it is used to generate a sitemap xml file, and that file can be accessed by http://domain.tls/sitemap.xml. and i want something like that.

So currently i'am achieving this by building the project, then manually put ads.txt it in : /var/www/site/.nuxt/dist/client/,

The problem with this is that everytime i rebuild the project i loose /var/www/site/.nuxt/dist/client/ folder then i have to add ads.txt file again.

I would like to know how i can hook up my code to tell nuxt to generate ads.txt file and put it in /var/www/site/.nuxt/dist/client/


Not sure if it makes sense, but i hope someone will understand.

like image 827
chawila Avatar asked Jan 22 '26 10:01

chawila


1 Answers

Place your ads.txt file in a directory named static as mentioned here. All the contents of the static directory can be accessed via example.com/{filename.extension}

enter image description here

If you are not using nuxt.js and just using vue js, place it in a public directory right next to src directory.

enter image description here

like image 192
navule Avatar answered Jan 25 '26 19:01

navule