Updating header <meta> when assigns update?

I have a liveview that needs to get content from an api that takes longer than the liveview process will allow to get data back before timing out. We solved this by fetching that data async and updating the assigns with the content. Problem is that some of the content we need to update via assigns for SEO purposes is in the <head> and it appears that updating assigns does not update content in the root_layout/<head>, with the exception of @page_title. Is there a way to force a re-render with the new assigns?

I’m not aware of any SEO/ meta tag reading tool, which would read the header after having connected LV via websockets. Therefore there’s not really a usecase for updating meta tags.

2 Likes

right, this is on a staging env and they want to verify visually i think that its coming through. prod works fine.

Do a full page refresh and you should see the adjusted values.

like a borwser refresh? that doesn’t seem to work

if the meta info is loading only via async (not ever rendered the “dead” render inline), then the meta info is essentially useless because it won’t be seen by crawlers. What @LostKobrakai is saying is that it’s fine to render the meta only on dead render and not worry about updating it for live navigate because at that point it won’t matter to crawlers anyway and a regular page visit (ie hard refresh) will show the correct meta. But if you only ever load the meta tags async via LV then they are worse than useless :slight_smile:

i get its useless for SEO purposes, but the powers that be want the SEO team to be able to verify (visually) its getting there in this particular staging env where we have to fetch the data async from lower env apis that are slow. so was just wondering if there were a way to make that happen for them. it appears there is not, which is probably fine. I appreciate the input from both of you, thanks!

You can make it happen via javascript with push_event on the server to a hook that updates the head, just keep in mind (as you probably know), that this would be only accommodating some bureaucratic checklists as all bets are off if this is the way it would really behave on production for the non-staging flow of actually rendering the meta tags over the HTTP request

Yeah I agree, seems like at that point they would just be testing this arbitrary hook in a lower env and not how the page actually renders in production.

So with all warnings and alarms being posted, here is the link

  • You can skip the warning about not using the low level Head lib.
  • the ‘Phx.Live.Metadata’ mentioned in the docs is non existing yet.