Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Html different on server vs locally

theme

Started by Jeffrey Bennett 6 years ago · 1 replies · 694 views
6 years ago

I've been making a site locally using Laragon and just uploaded it to my host. When I did that, the styling of my site's header changed. My heading code:

TWIG
{% set splitTitle = site.title|split("") %}
{% set finalTitle = "" %}

{% for letter in splitTitle  %}
    {% switch finalTitle|length %}
        {% case 0 %}
            {% set finalTitle = finalTitle~letter~"<span>" %}
        {% case titleLength %}
            {% set finalTitle = finalTitle~"</span>"~letter %}
        {% default %}
            {% set finalTitle = finalTitle~letter %}
          {% set titleLength = splitTitle|length+5 %}
    {% endswitch %}
{% endfor %}

<div class="clearfix">
   <a href="{{ home_url }}"><h1 class="header-site-title">{{ finalTitle }}</h1></a>
</div>

The style is changing because the hosted version is putting the <a> tag inside of the <h1> tag. Is there any logical reason this would be happening?

last edited 12/04/20 by Jeffrey Bennett
6 years ago

Hi @Jrbdog -

There are so many potential variables here. Clearly, something in your local environment is different than your production environment. The question is how to determine that. This is why I spent a lot of time configuring my local environment to use the same platforms as my host.

Several considerations:

  • run a diff on both code sets - make sure they are in sync.
  • set some debug statements in the above code to trace the values - maybe something pops out
  • make sure your config files are not being overridden by server config files.

This last one is always hard to see. If you save config info from the admin while logged into the server, it will not change the original config file, but instead create an overriding one in a folder named after the URL. If something is switched on or off in these files, it can change the behavior of the whole platform. I use this on purpose, to turn off things like the debugger, no matter what my local settings are.

I hope you figure it out.

  • Φ

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 99 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 186 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 62 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 257 1 year ago