Hi,
In a LiveView app, I want to setup different meta tags for some pages. For example, on a user profile page, I want to add user specific meta title and description.
In mount function, I set :profile_meta to true
def mount(_params, %{"user_token" => user_token} = _session, socket) do
current_user = Accounts.get_user_by_session_token(user_token)
{:ok,
socket
|> assign(:current_user, current_user)
|> assign(:profile_meta, true)}
end
In the head section I have the following:
<%= if @profile_meta do %>
<meta property="og:title" content={"#{@profile.name}"} />
<meta property="og:description" content={"#{@profile.about} "} />
<% else %>
...
When the profile page is opened in the browser, meta tags are loaded properly in the head tag as they should be.
The problem is that when sharing those page on social media, the data is not loaded because those websites don’t use javascript when scraping meta tags so mount function doesn’t happen and profile_meta: true is never assigned.
What would be the best way to handle this?






















