Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to include a header in a bunch of pages, like so:


    <title>My site</title>

To enable a page-specific title, I'm trying to use an SSI variable that I set in each page:


<!--#set var="TITLE" value="first page" -->
<!--#include file="header.html" -->

Then I”m modifying header.html to use that variable:

<title>My site - <!--#echo var="TITLE" --></title>

This works fine but, of course, it has the unfortunate effect that, if TITLE is not set, the result is:

<title>My site - (none)</title>

So I'm trying a variety of attempts at conditionally echoing that variable depending on whether it's none or not (e.g., <!--#if expr="TITLE != \(none\)" --> ... <!--#endif-->) …but nothing seems to work.

Seems like this would be quite a common requirement. Does anyone have a reference to a working solution?

share|improve this question
up vote 0 down vote accepted

OK, solved it myself. For others' reference:

<!--#if expr="${TITLE}!=''" -->

is the correct syntax to use. It makes sense that you don't have to check for "(none)" since the undefined text value can be configured; I just didn't realised that occurred after checking the value, not before.

share|improve this answer

I've used this successfully:

<!--#if expr="! $CONTENT_LANGUAGE" -->
<!--#set var="CONTENT_LANGUAGE" value="en" -->
<!--#endif -->
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.