Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta tags: Potential bug or documentation inconsistency #996

Open
JovanVeljanoski opened this issue Feb 6, 2025 · 2 comments
Open

Meta tags: Potential bug or documentation inconsistency #996

JovanVeljanoski opened this issue Feb 6, 2025 · 2 comments

Comments

@JovanVeljanoski
Copy link
Collaborator

Hi!

When looking at the docstrings of solara.Head we see this:

A component that manager the "head" tag of the page to avoid duplicate tags, such as titles.

    Currently only supports the [title](/documentation/components/page/title) tag as child, e.g.:

    ```python
    import solara

    @solara.component
    def Page():
        with solara.VBox() as main:
            MyAwesomeComponent()
            with solara.Head():
                solara.Title("My page title")
        return main
    ```

However in the docs of solara.Meta we see that this can also be in the solara.Head :

"""Add a meta tag to the head element, or replace a meta tag with the same name and or property.

    This component should be used inside a [Head](/documentation/components/page/head) component, e.g.:

    ```python
    import solara

    @solara.component
    def Page():
        with solara.VBox() as main:
            MyAwesomeComponent()
            with solara.Head():
                solara.Meta(name="description", property="og:description", content="My page description")
                solara.Meta(property="og:title", content="My page title for social media")
                solara.Meta(property="og:image", content="https://solara.dev/static/assets/images/logo.svg")
                solara.Meta(property="og:type", content="website")
        return main
    ```

Anyway, my point is.. i have been trying various approaches and I can't get the open-graph tags to propaga to the head correctly.
I have tried various attempts to include them in my Layout component (which is practically identical to the one solara offers for multi-page apps, with an attempt to add the meta og tags).

I have also tried following the example from the solara.dev page itself that is also in the solara repo, but also nothing.
Either there is some funny bug, or am i doing something wrong (probably the latter since the solara.dev website works).

Can someone please explain what is the expected way of using these components to add the OG/Twitter tags?

Many thanks!

@JovanVeljanoski JovanVeljanoski changed the title Potential bug or documentation inconsistency Meta tags: Potential bug or documentation inconsistency Feb 6, 2025
@iisakkirotko
Copy link
Collaborator

Hey Jovan!

I think you're right in everything you say:

  • Our documentation of solara.Head is incorrect, and should also accept Meta elements.
  • There is some funny bug going on with the Meta tags. (I'm looking into it)

I'm not sure if you were already running SSG, but I think most likely in order for the og tags to be picked up they need to be present in the raw HTML that the server sends. So you need to run SSG in order for them to work.

@JovanVeljanoski
Copy link
Collaborator Author

Hi!

Thanks for the swift response!

I looked into the code and to the best of my understanding, anything with SSG is solara enterprise territory, so I do not want to touch it.

Also, I kind of figured out that if i edit the "base" server template and add tags manually there, things work as expected. But it is not nice thing to do. Maybe if there can be a way to use a custom "base template" ( I ask that here ), that would solve things.

On the other and solara.Title() works as expected!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants